Make matchConditionsFeatureGateInitiallyEnabled a boolean instead

This commit is contained in:
Amine 2023-07-17 18:34:42 +01:00
parent 6b3ce3004d
commit 00de051729

View File

@ -730,20 +730,20 @@ func TestMatchConditions_validation(t *testing.T) {
func TestFeatureGateEnablement(t *testing.T) {
testcases := []struct {
name string
matchConditionsFeatureGateInitiaState string
matchConditionsFeatureGateInitiallyEnabled bool
matchConditions []admissionregistrationv1.MatchCondition
expectMatchConditionsPreSwitch bool
expectMatchConditionsPostSwitch bool
}{
{
name: "start with match conditions enabled - no match conditions",
matchConditionsFeatureGateInitiaState: "enabled",
matchConditionsFeatureGateInitiallyEnabled: true,
expectMatchConditionsPreSwitch: false,
expectMatchConditionsPostSwitch: false,
},
{
name: "start with match conditions enabled - with match conditions",
matchConditionsFeatureGateInitiaState: "enabled",
matchConditionsFeatureGateInitiallyEnabled: true,
matchConditions: []admissionregistrationv1.MatchCondition{{
Name: "test-expression",
Expression: "true",
@ -753,13 +753,13 @@ func TestFeatureGateEnablement(t *testing.T) {
},
{
name: "start with match conditions disabled - no match conditions",
matchConditionsFeatureGateInitiaState: "disabled",
matchConditionsFeatureGateInitiallyEnabled: false,
expectMatchConditionsPreSwitch: false,
expectMatchConditionsPostSwitch: false,
},
{
name: "start with match conditions disabled - with match conditions",
matchConditionsFeatureGateInitiaState: "disabled",
matchConditionsFeatureGateInitiallyEnabled: false,
matchConditions: []admissionregistrationv1.MatchCondition{{
Name: "test-expression",
Expression: "true",
@ -794,7 +794,7 @@ func TestFeatureGateEnablement(t *testing.T) {
for _, testcase := range testcases {
t.Run(testcase.name, func(t *testing.T) {
if testcase.matchConditionsFeatureGateInitiaState == "enabled" {
if testcase.matchConditionsFeatureGateInitiallyEnabled {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.AdmissionWebhookMatchConditions, true)()
}
@ -887,7 +887,7 @@ func TestFeatureGateEnablement(t *testing.T) {
}
// Switch the featureGate state
if testcase.matchConditionsFeatureGateInitiaState == "enabled" {
if testcase.matchConditionsFeatureGateInitiallyEnabled {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.AdmissionWebhookMatchConditions, false)()
} else {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, genericfeatures.AdmissionWebhookMatchConditions, true)()