blob: 3cccd14f9151e6576e32c5f74038c37823a70921 [file] [log] [blame]
Lorenz Brund58edf42024-11-27 20:38:14 +00001package kubernetes
2
3import (
4 "testing"
5
6 utilfeature "k8s.io/apiserver/pkg/util/feature"
7 "k8s.io/component-base/featuregate"
8)
9
10func TestFeatureGateDefaults(t *testing.T) {
11 for f, en := range extraFeatureGates {
12 if utilfeature.DefaultFeatureGate.Enabled(f) == en {
13 t.Errorf("Feature gate %q is already %v by default, remove it from extraFeatureGates", string(f), en)
14 }
15 }
16}
17
18func TestAsFlags(t *testing.T) {
19 for _, c := range []struct {
20 name string
21 fg featureGates
22 expected string
23 }{
24 {"None", featureGates{}, "--feature-gates="},
25 {"Single", featureGates{featuregate.Feature("Test"): true}, "--feature-gates=Test=true"},
26 {"Multiple", featureGates{featuregate.Feature("Test"): true, featuregate.Feature("Test2"): false}, "--feature-gates=Test=true,Test2=false"},
27 } {
28 t.Run(c.name, func(t *testing.T) {
29 got := c.fg.AsFlag()
30 if got != c.expected {
31 t.Errorf("Expected %q, got %q", c.expected, got)
32 }
33 })
34 }
35}