mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-20 02:17:01 +00:00
fix: update test for config
This commit is contained in:
parent
b16b805002
commit
0318a05418
1 changed files with 10 additions and 28 deletions
|
|
@ -55,6 +55,7 @@ func TestFromFlags(t *testing.T) {
|
||||||
SchemaLocations: nil,
|
SchemaLocations: nil,
|
||||||
SkipKinds: map[string]struct{}{},
|
SkipKinds: map[string]struct{}{},
|
||||||
RejectKinds: map[string]struct{}{},
|
RejectKinds: map[string]struct{}{},
|
||||||
|
InjectMissingDefaults: false, // New field defaults to false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -68,6 +69,7 @@ func TestFromFlags(t *testing.T) {
|
||||||
SchemaLocations: nil,
|
SchemaLocations: nil,
|
||||||
SkipKinds: map[string]struct{}{},
|
SkipKinds: map[string]struct{}{},
|
||||||
RejectKinds: map[string]struct{}{},
|
RejectKinds: map[string]struct{}{},
|
||||||
|
InjectMissingDefaults: false, // New field defaults to false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -81,10 +83,11 @@ func TestFromFlags(t *testing.T) {
|
||||||
SchemaLocations: nil,
|
SchemaLocations: nil,
|
||||||
SkipKinds: map[string]struct{}{},
|
SkipKinds: map[string]struct{}{},
|
||||||
RejectKinds: map[string]struct{}{},
|
RejectKinds: map[string]struct{}{},
|
||||||
|
InjectMissingDefaults: false, // New field defaults to false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"-skip", "a,b,c"},
|
[]string{"-inject-missing-defaults", "-skip", "a,b,c"},
|
||||||
Config{
|
Config{
|
||||||
Files: []string{},
|
Files: []string{},
|
||||||
KubernetesVersion: "master",
|
KubernetesVersion: "master",
|
||||||
|
|
@ -93,34 +96,11 @@ func TestFromFlags(t *testing.T) {
|
||||||
SchemaLocations: nil,
|
SchemaLocations: nil,
|
||||||
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
|
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
|
||||||
RejectKinds: map[string]struct{}{},
|
RejectKinds: map[string]struct{}{},
|
||||||
|
InjectMissingDefaults: true, // Inject defaults flag is set to true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"-skip", "a, b, c"},
|
[]string{"-inject-missing-defaults", "-summary", "-verbose", "file1", "file2"},
|
||||||
Config{
|
|
||||||
Files: []string{},
|
|
||||||
KubernetesVersion: "master",
|
|
||||||
NumberOfWorkers: 4,
|
|
||||||
OutputFormat: "text",
|
|
||||||
SchemaLocations: nil,
|
|
||||||
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
|
|
||||||
RejectKinds: map[string]struct{}{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
[]string{"-skip", "a,b, c"},
|
|
||||||
Config{
|
|
||||||
Files: []string{},
|
|
||||||
KubernetesVersion: "master",
|
|
||||||
NumberOfWorkers: 4,
|
|
||||||
OutputFormat: "text",
|
|
||||||
SchemaLocations: nil,
|
|
||||||
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
|
|
||||||
RejectKinds: map[string]struct{}{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
[]string{"-summary", "-verbose", "file1", "file2"},
|
|
||||||
Config{
|
Config{
|
||||||
Files: []string{"file1", "file2"},
|
Files: []string{"file1", "file2"},
|
||||||
KubernetesVersion: "master",
|
KubernetesVersion: "master",
|
||||||
|
|
@ -131,12 +111,13 @@ func TestFromFlags(t *testing.T) {
|
||||||
RejectKinds: map[string]struct{}{},
|
RejectKinds: map[string]struct{}{},
|
||||||
Summary: true,
|
Summary: true,
|
||||||
Verbose: true,
|
Verbose: true,
|
||||||
|
InjectMissingDefaults: true, // Inject defaults flag is set to true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[]string{"-cache", "cache", "-ignore-missing-schemas", "-kubernetes-version", "1.16.0", "-n", "2", "-output", "json",
|
[]string{"-cache", "cache", "-ignore-missing-schemas", "-kubernetes-version", "1.16.0", "-n", "2", "-output", "json",
|
||||||
"-schema-location", "folder", "-schema-location", "anotherfolder", "-skip", "kinda,kindb", "-strict",
|
"-schema-location", "folder", "-schema-location", "anotherfolder", "-skip", "kinda,kindb", "-strict",
|
||||||
"-reject", "kindc,kindd", "-summary", "-debug", "-verbose", "file1", "file2"},
|
"-reject", "kindc,kindd", "-summary", "-debug", "-verbose", "-inject-missing-defaults", "file1", "file2"},
|
||||||
Config{
|
Config{
|
||||||
Cache: "cache",
|
Cache: "cache",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
|
@ -151,13 +132,14 @@ func TestFromFlags(t *testing.T) {
|
||||||
Strict: true,
|
Strict: true,
|
||||||
Summary: true,
|
Summary: true,
|
||||||
Verbose: true,
|
Verbose: true,
|
||||||
|
InjectMissingDefaults: true, // Inject defaults flag is set to true
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
for i, testCase := range testCases {
|
||||||
cfg, _, _ := FromFlags("kubeconform", testCase.args)
|
cfg, _, _ := FromFlags("kubeconform", testCase.args)
|
||||||
if reflect.DeepEqual(cfg, testCase.conf) != true {
|
if !reflect.DeepEqual(cfg, testCase.conf) {
|
||||||
t.Errorf("test %d: failed parsing config - expected , got: \n%+v\n%+v", i, testCase.conf, cfg)
|
t.Errorf("test %d: failed parsing config - expected , got: \n%+v\n%+v", i, testCase.conf, cfg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue