@@ -10,7 +10,11 @@ import (
10
10
11
11
"github.com/stretchr/testify/assert"
12
12
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
+ "k8s.io/apimachinery/pkg/util/sets"
14
+
13
15
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
16
+ "sigs.k8s.io/gateway-api/conformance/utils/suite"
17
+ "sigs.k8s.io/gateway-api/pkg/features"
14
18
)
15
19
16
20
func TestComputeGatewayClassAcceptedCondition (t * testing.T ) {
@@ -66,3 +70,58 @@ func TestComputeGatewayClassAcceptedCondition(t *testing.T) {
66
70
assert .Equal (t , gc .Generation , got .ObservedGeneration )
67
71
}
68
72
}
73
+
74
+ func TestGetSupportedFeatures (t * testing.T ) {
75
+ testCases := []struct {
76
+ name string
77
+ gatewaySuite suite.ConformanceOptions
78
+ skippedTests []suite.ConformanceTest
79
+ expectedResult []gwapiv1.SupportedFeature
80
+ }{
81
+ {
82
+ name : "No exempt features" ,
83
+ gatewaySuite : suite.ConformanceOptions {
84
+ SupportedFeatures : sets .New [features.SupportedFeature ]("Gateway" , "HTTPRoute" ),
85
+ ExemptFeatures : sets .New [features.SupportedFeature ](),
86
+ },
87
+ expectedResult : []gwapiv1.SupportedFeature {"Gateway" , "HTTPRoute" },
88
+ },
89
+ {
90
+ name : "All features exempt" ,
91
+ gatewaySuite : suite.ConformanceOptions {
92
+ SupportedFeatures : sets .New [features.SupportedFeature ]("Gateway" , "HTTPRoute" ),
93
+ ExemptFeatures : sets .New [features.SupportedFeature ]("Gateway" , "HTTPRoute" ),
94
+ },
95
+ expectedResult : []gwapiv1.SupportedFeature {},
96
+ },
97
+ {
98
+ name : "Some features exempt" ,
99
+ gatewaySuite : suite.ConformanceOptions {
100
+ SupportedFeatures : sets .New [features.SupportedFeature ]("Gateway" , "HTTPRoute" , "GRPCRoute" ),
101
+ ExemptFeatures : sets.New [features.SupportedFeature ]("GRPCRoute" ),
102
+ },
103
+ expectedResult : []gwapiv1.SupportedFeature {"Gateway" , "HTTPRoute" },
104
+ },
105
+ {
106
+ name : "Some features exempt with skipped tests" ,
107
+ gatewaySuite : suite.ConformanceOptions {
108
+ SupportedFeatures : sets .New [features.SupportedFeature ]("Gateway" , "HTTPRoute" , "GRPCRoute" ),
109
+ ExemptFeatures : sets.New [features.SupportedFeature ]("GRPCRoute" ),
110
+ },
111
+ skippedTests : []suite.ConformanceTest {
112
+ {
113
+ Features : []features.SupportedFeature {"HTTPRoute" },
114
+ },
115
+ },
116
+ expectedResult : []gwapiv1.SupportedFeature {"Gateway" },
117
+ },
118
+ }
119
+
120
+ for _ , tc := range testCases {
121
+ t .Run (tc .name , func (t * testing.T ) {
122
+ result := getSupportedFeatures (tc .gatewaySuite , tc .skippedTests )
123
+
124
+ assert .ElementsMatch (t , tc .expectedResult , result , "The result should match the expected output for the test case." )
125
+ })
126
+ }
127
+ }
0 commit comments