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>
55 lines
829 B
Go
55 lines
829 B
Go
package match
|
|
|
|
import "testing"
|
|
|
|
func TestCheckName(t *testing.T) {
|
|
type args struct {
|
|
expected string
|
|
actual string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
want bool
|
|
}{{
|
|
args: args{},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
expected: "",
|
|
actual: "foo",
|
|
},
|
|
want: false,
|
|
}, {
|
|
args: args{
|
|
expected: "*",
|
|
actual: "foo",
|
|
},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
expected: "foo",
|
|
actual: "foo",
|
|
},
|
|
want: true,
|
|
}, {
|
|
args: args{
|
|
expected: "bar",
|
|
actual: "foo",
|
|
},
|
|
want: false,
|
|
}, {
|
|
args: args{
|
|
expected: "f?o",
|
|
actual: "foo",
|
|
},
|
|
want: true,
|
|
}}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := CheckName(tt.args.expected, tt.args.actual); got != tt.want {
|
|
t.Errorf("CheckName() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|