|
| 1 | +package status |
| 2 | + |
| 3 | +import ( |
| 4 | + "slices" |
| 5 | + "testing" |
| 6 | + |
| 7 | + . "github.com/onsi/gomega" |
| 8 | + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" |
| 9 | +) |
| 10 | + |
| 11 | +func TestSupportedFeatures(t *testing.T) { |
| 12 | + t.Parallel() |
| 13 | + g := NewWithT(t) |
| 14 | + |
| 15 | + features := SupportedFeatures() |
| 16 | + |
| 17 | + // Verify we have the expected features |
| 18 | + expectedFeatures := []gatewayv1.FeatureName{ |
| 19 | + "BackendTLSPolicy", |
| 20 | + "GatewayAddressEmpty", |
| 21 | + "GatewayHTTPListenerIsolation", |
| 22 | + "GatewayInfrastructurePropagation", |
| 23 | + "GatewayPort8080", |
| 24 | + "GatewayStaticAddresses", |
| 25 | + "HTTPRouteBackendProtocolWebSocket", |
| 26 | + "HTTPRouteDestinationPortMatching", |
| 27 | + "HTTPRouteHostRewrite", |
| 28 | + "HTTPRouteMethodMatching", |
| 29 | + "HTTPRouteParentRefPort", |
| 30 | + "HTTPRoutePathRedirect", |
| 31 | + "HTTPRoutePathRewrite", |
| 32 | + "HTTPRoutePortRedirect", |
| 33 | + "HTTPRouteQueryParamMatching", |
| 34 | + "HTTPRouteRequestMirror", |
| 35 | + "HTTPRouteRequestMultipleMirrors", |
| 36 | + "HTTPRouteRequestPercentageMirror", |
| 37 | + "HTTPRouteResponseHeaderModification", |
| 38 | + "HTTPRouteSchemeRedirect", |
| 39 | + } |
| 40 | + |
| 41 | + g.Expect(features).To(HaveLen(len(expectedFeatures))) |
| 42 | + |
| 43 | + // Verify all expected features are present |
| 44 | + for _, expected := range expectedFeatures { |
| 45 | + g.Expect(slices.ContainsFunc(features, func(f gatewayv1.SupportedFeature) bool { |
| 46 | + return f.Name == expected |
| 47 | + })).To(BeTrue(), "expected feature %s not found", expected) |
| 48 | + } |
| 49 | + |
| 50 | + // Verify the list is sorted alphabetically |
| 51 | + g.Expect(slices.IsSortedFunc(features, func(a, b gatewayv1.SupportedFeature) int { |
| 52 | + if a.Name < b.Name { |
| 53 | + return -1 |
| 54 | + } |
| 55 | + if a.Name > b.Name { |
| 56 | + return 1 |
| 57 | + } |
| 58 | + return 0 |
| 59 | + })).To(BeTrue(), "features should be sorted alphabetically") |
| 60 | +} |
0 commit comments