mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
2a22e8762a
* refactor: match utils package Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * test Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * test Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * test Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
112 lines
1.9 KiB
Go
112 lines
1.9 KiB
Go
package match
|
|
|
|
import "testing"
|
|
|
|
func TestCheckAnnotations(t *testing.T) {
|
|
type args struct {
|
|
expected map[string]string
|
|
actual map[string]string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want bool
|
|
}{{
|
|
args: args{
|
|
expected: map[string]string{},
|
|
actual: map[string]string{},
|
|
},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
expected: map[string]string{
|
|
"test/*": "*",
|
|
},
|
|
actual: map[string]string{},
|
|
},
|
|
want: false,
|
|
}, {
|
|
args: args{
|
|
expected: map[string]string{
|
|
"test/*": "*",
|
|
},
|
|
actual: map[string]string{
|
|
"tes1/test": "*",
|
|
},
|
|
},
|
|
want: false,
|
|
}, {
|
|
args: args{
|
|
expected: map[string]string{
|
|
"test/*": "*",
|
|
},
|
|
actual: map[string]string{
|
|
"test/test": "*",
|
|
},
|
|
},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
expected: map[string]string{
|
|
"test/*": "*",
|
|
},
|
|
actual: map[string]string{
|
|
"test/bar": "foo",
|
|
},
|
|
},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
expected: map[string]string{
|
|
"test/b*": "*",
|
|
},
|
|
actual: map[string]string{
|
|
"test/bar": "foo",
|
|
},
|
|
},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
expected: map[string]string{
|
|
"test/b*": "*",
|
|
"test2/*": "*",
|
|
},
|
|
actual: map[string]string{
|
|
"test/bar": "foo",
|
|
},
|
|
},
|
|
want: false,
|
|
}, {
|
|
args: args{
|
|
expected: map[string]string{
|
|
"test/b*": "*",
|
|
"test2/*": "*",
|
|
},
|
|
actual: map[string]string{
|
|
"test/bar": "foo",
|
|
"test2/123": "bar",
|
|
},
|
|
},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
expected: map[string]string{
|
|
"test/b*": "*",
|
|
"test2/*": "*",
|
|
},
|
|
actual: map[string]string{
|
|
"test/bar": "foo",
|
|
"test2/123": "bar",
|
|
"test3/123": "bar2",
|
|
},
|
|
},
|
|
want: true,
|
|
}}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := CheckAnnotations(tt.args.expected, tt.args.actual); got != tt.want {
|
|
t.Errorf("CheckAnnotations() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|