diff options
Diffstat (limited to 'registry-scanner/pkg/image/matchfunc_test.go')
| -rw-r--r-- | registry-scanner/pkg/image/matchfunc_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/registry-scanner/pkg/image/matchfunc_test.go b/registry-scanner/pkg/image/matchfunc_test.go new file mode 100644 index 0000000..11929b1 --- /dev/null +++ b/registry-scanner/pkg/image/matchfunc_test.go @@ -0,0 +1,27 @@ +package image + +import ( + "regexp" + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_MatchFuncAny(t *testing.T) { + assert.True(t, MatchFuncAny("whatever", nil)) +} + +func Test_MatchFuncNone(t *testing.T) { + assert.False(t, MatchFuncNone("whatever", nil)) +} + +func Test_MatchFuncRegexp(t *testing.T) { + t.Run("Test with valid expression", func(t *testing.T) { + re := regexp.MustCompile("[a-z]+") + assert.True(t, MatchFuncRegexp("lemon", re)) + assert.False(t, MatchFuncRegexp("31337", re)) + }) + t.Run("Test with invalid type", func(t *testing.T) { + assert.False(t, MatchFuncRegexp("lemon", "[a-z]+")) + }) +} |
