mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-31 08:36:16 +00:00
Merge pull request #125723 from p0lyn0mial/upstream-refactor-watch-list-kcm-units
kube-controller-manager: refactor watchlist unit tests
This commit is contained in:
@@ -1320,35 +1320,26 @@ func TestControllerManagerAliases(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWatchListClientFlagUsage(t *testing.T) {
|
||||
assertWatchListClientFeatureDefaultValue(t)
|
||||
|
||||
fs := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
|
||||
s, _ := NewKubeControllerManagerOptions()
|
||||
for _, f := range s.Flags([]string{""}, []string{""}, nil).FlagSets {
|
||||
fs.AddFlagSet(f)
|
||||
}
|
||||
|
||||
fgFlagName := "feature-gates"
|
||||
fg := fs.Lookup(fgFlagName)
|
||||
if fg == nil {
|
||||
t.Fatalf("didn't find %q flag", fgFlagName)
|
||||
}
|
||||
|
||||
expectedWatchListClientString := "WatchListClient=true|false (BETA - default=false)"
|
||||
if !strings.Contains(fg.Usage, expectedWatchListClientString) {
|
||||
t.Fatalf("%q flag doesn't contain the expected usage for %v feature gate.\nExpected = %v\nUsage = %v", fgFlagName, clientgofeaturegate.WatchListClient, expectedWatchListClientString, fg.Usage)
|
||||
}
|
||||
assertWatchListClientFeatureDefaultValue(t)
|
||||
assertWatchListCommandLineDefaultValue(t, fs)
|
||||
}
|
||||
|
||||
func TestWatchListClientFlagChange(t *testing.T) {
|
||||
assertWatchListClientFeatureDefaultValue(t)
|
||||
|
||||
fs := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
|
||||
s, _ := NewKubeControllerManagerOptions()
|
||||
for _, f := range s.Flags([]string{""}, []string{""}, nil).FlagSets {
|
||||
fs.AddFlagSet(f)
|
||||
}
|
||||
|
||||
assertWatchListClientFeatureDefaultValue(t)
|
||||
assertWatchListCommandLineDefaultValue(t, fs)
|
||||
|
||||
args := []string{fmt.Sprintf("--feature-gates=%v=true", clientgofeaturegate.WatchListClient)}
|
||||
if err := fs.Parse(args); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -1367,6 +1358,19 @@ func assertWatchListClientFeatureDefaultValue(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func assertWatchListCommandLineDefaultValue(t *testing.T, fs *pflag.FlagSet) {
|
||||
fgFlagName := "feature-gates"
|
||||
fg := fs.Lookup(fgFlagName)
|
||||
if fg == nil {
|
||||
t.Fatalf("didn't find %q flag", fgFlagName)
|
||||
}
|
||||
|
||||
expectedWatchListClientString := "WatchListClient=true|false (BETA - default=false)"
|
||||
if !strings.Contains(fg.Usage, expectedWatchListClientString) {
|
||||
t.Fatalf("%q flag doesn't contain the expected usage for %v feature gate.\nExpected = %v\nUsage = %v", fgFlagName, clientgofeaturegate.WatchListClient, expectedWatchListClientString, fg.Usage)
|
||||
}
|
||||
}
|
||||
|
||||
type sortedGCIgnoredResources []garbagecollectorconfig.GroupResource
|
||||
|
||||
func (r sortedGCIgnoredResources) Len() int {
|
||||
|
Reference in New Issue
Block a user