-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
352 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package ingress | ||
|
||
import ( | ||
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Parse component routes", func() { | ||
It("Parses input string for component routes", func() { | ||
componentRouteBuilder, err := parseComponentRoutes( | ||
//nolint:lll | ||
"oauth: hostname=oauth-host;tlsSecretRef=oauth-secret,downloads: hostname=downloads-host;tlsSecretRef=downloads-secret,console: hostname=console-host;tlsSecretRef=console-secret", | ||
) | ||
Expect(err).To(BeNil()) | ||
for key, builder := range componentRouteBuilder { | ||
expectedHostname := fmt.Sprintf("%s-host", key) | ||
expectedTlsRef := fmt.Sprintf("%s-secret", key) | ||
componentRoute, err := builder.Build() | ||
Expect(err).To(BeNil()) | ||
Expect(componentRoute.Hostname()).To(Equal(expectedHostname)) | ||
Expect(componentRoute.TlsSecretRef()).To(Equal(expectedTlsRef)) | ||
} | ||
}) | ||
Context("Fails to parse input string for component routes", func() { | ||
It("fails due to invalid component route", func() { | ||
_, err := parseComponentRoutes( | ||
//nolint:lll | ||
"unknown: hostname=oauth-host;tlsSecretRef=oauth-secret,downloads: hostname=downloads-host;tlsSecretRef=downloads-secret,console: hostname=console-host;tlsSecretRef=console-secret", | ||
) | ||
Expect(err).ToNot(BeNil()) | ||
Expect( | ||
err.Error(), | ||
).To(Equal("'unknown' is not a valid component name. Expected include [oauth, console, downloads]")) | ||
}) | ||
It("fails due to wrong amount of component routes", func() { | ||
_, err := parseComponentRoutes( | ||
//nolint:lll | ||
"oauth: hostname=oauth-host;tlsSecretRef=oauth-secret,downloads: hostname=downloads-host;tlsSecretRef=downloads-secret", | ||
) | ||
Expect(err).ToNot(BeNil()) | ||
Expect( | ||
err.Error(), | ||
).To(Equal("the expected amount of component routes is 3, but 2 have been supplied")) | ||
}) | ||
It("fails if it can split ':' in more than they key separation", func() { | ||
_, err := parseComponentRoutes( | ||
//nolint:lll | ||
"oauth: hostname=oauth:-host;tlsSecretRef=oauth-secret,downloads: hostname=downloads-host;tlsSecretRef=downloads-secret,", | ||
) | ||
Expect(err).ToNot(BeNil()) | ||
Expect( | ||
err.Error(), | ||
).To(Equal("only the name of the component should be followed by ':'")) | ||
}) | ||
It("fails due to invalid parameter", func() { | ||
_, err := parseComponentRoutes( | ||
//nolint:lll | ||
"oauth: unknown=oauth-host;tlsSecretRef=oauth-secret,downloads: hostname=downloads-host;tlsSecretRef=downloads-secret,console: hostname=console-host;tlsSecretRef=console-secret", | ||
) | ||
Expect(err).ToNot(BeNil()) | ||
Expect( | ||
err.Error(), | ||
).To(Equal("'unknown' is not a valid parameter for a component route. Expected include [hostname, tlsSecretRef]")) | ||
}) | ||
It("fails due to wrong amount of parameters", func() { | ||
_, err := parseComponentRoutes( | ||
//nolint:lll | ||
"oauth: hostname=oauth-host,downloads: hostname=downloads-host;tlsSecretRef=downloads-secret,console: hostname=console-host;tlsSecretRef=console-secret", | ||
) | ||
Expect(err).ToNot(BeNil()) | ||
Expect( | ||
err.Error(), | ||
).To(Equal("only 2 parameters are expected for each component")) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ingress | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestEditCluster(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Edit ingress suite") | ||
} |
Oops, something went wrong.