mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-30 03:15:05 +00:00
test: add config unit test (#6595)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: shuting <shuting@nirmata.com>
This commit is contained in:
parent
2270da0597
commit
818b92bf60
1 changed files with 37 additions and 0 deletions
|
@ -179,3 +179,40 @@ func Test_parseIncludeExcludeNamespacesFromNamespacesConfig(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_parseWebhookAnnotations(t *testing.T) {
|
||||
type args struct {
|
||||
in string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want map[string]string
|
||||
wantErr bool
|
||||
}{{
|
||||
args: args{"hello"},
|
||||
wantErr: true,
|
||||
}, {
|
||||
args: args{""},
|
||||
wantErr: true,
|
||||
}, {
|
||||
args: args{"null"},
|
||||
}, {
|
||||
args: args{`{"a": "b"}`},
|
||||
want: map[string]string{
|
||||
"a": "b",
|
||||
},
|
||||
}}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := parseWebhookAnnotations(tt.args.in)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("parseWebhookAnnotations() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("parseWebhookAnnotations() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue