package common import "testing" func TestMatch(t *testing.T) { type args struct { pattern string name string } tests := []struct { name string args args wantMatched bool }{ {name: "t1", args: args{name: "wx/nginx", pattern: "*"}, wantMatched: true}, {name: "t2", args: args{name: "wx/nginx", pattern: "wx/*"}, wantMatched: true}, {name: "t3", args: args{name: "wx/nginx", pattern: "*/nginx"}, wantMatched: true}, {name: "t4", args: args{name: "wx/nginx", pattern: "wx*nginx"}, wantMatched: true}, {name: "t5", args: args{name: "wx/nginx", pattern: "wx?nginx"}, wantMatched: true}, {name: "t6", args: args{name: "harbor.linkfog.com:8443/wx/ubuntu", pattern: "*wx?ubuntu*"}, wantMatched: true}, {name: "t7", args: args{name: "harbor.linkfog.com:8443/wx/ubuntu", pattern: "*wx*"}, wantMatched: true}, {name: "t8", args: args{name: "harbor.linkfog.com:8443/wx/ubuntu", pattern: "harbor*"}, wantMatched: true}, {name: "t9", args: args{name: "harbor.linkfog.com:8443/wx/ubuntu", pattern: "*ubuntu"}, wantMatched: true}, {name: "t10", args: args{name: "**", pattern: "*"}, wantMatched: true}, {name: "t11", args: args{name: "**", pattern: "??"}, wantMatched: true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if gotMatched := Match(tt.args.pattern, tt.args.name); gotMatched != tt.wantMatched { t.Errorf("Match() = %v, want %v", gotMatched, tt.wantMatched) } }) } }