Skip to content

Commit

Permalink
Merge pull request #14 from asalkeld/unit-tests
Browse files Browse the repository at this point in the history
Unit tests for isCAPIFeatureGateEnabled
  • Loading branch information
openshift-merge-robot committed Nov 18, 2021
2 parents bf4912a + e1bd839 commit 57857a7
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions pkg/controllers/feature_gate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package controllers

import (
"testing"

configv1 "github.com/openshift/api/config/v1"
)

func TestIsCAPIFeatureGateEnabled(t *testing.T) {
tests := []struct {
name string
featureGate *configv1.FeatureGate
want bool
wantErr bool
}{
{
name: "custom enabled",
featureGate: &configv1.FeatureGate{
Spec: configv1.FeatureGateSpec{
FeatureGateSelection: configv1.FeatureGateSelection{
FeatureSet: configv1.CustomNoUpgrade,
CustomNoUpgrade: &configv1.CustomFeatureGates{Enabled: []string{ClusterAPIEnabled}},
},
},
},
want: true,
},
{
name: "default not enabled",
featureGate: &configv1.FeatureGate{
Spec: configv1.FeatureGateSpec{
FeatureGateSelection: configv1.FeatureGateSelection{
FeatureSet: configv1.Default,
},
},
},
want: false,
},
{
name: "techpreview not enabled", // TODO this will change
featureGate: &configv1.FeatureGate{
Spec: configv1.FeatureGateSpec{
FeatureGateSelection: configv1.FeatureGateSelection{
FeatureSet: configv1.TechPreviewNoUpgrade,
},
},
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := isCAPIFeatureGateEnabled(tt.featureGate)
if (err != nil) != tt.wantErr {
t.Errorf("isCAPIFeatureGateEnabled() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("isCAPIFeatureGateEnabled() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 57857a7

Please sign in to comment.