summaryrefslogtreecommitdiff
path: root/registry-scanner/pkg/image/matchfunc_test.go
diff options
context:
space:
mode:
authorIshita Sequeira <46771830+ishitasequeira@users.noreply.github.com>2024-12-04 21:34:58 +0530
committerGitHub <noreply@github.com>2024-12-04 11:04:58 -0500
commit8076d2005ea625c73604073fca43df38eb675751 (patch)
tree1570ba5969882a26e021875da86bee6850a9cfc6 /registry-scanner/pkg/image/matchfunc_test.go
parentc3f0eff54daf871fa1c274462b17f5149c11d368 (diff)
Add image folder to registry scanner (#952)
Signed-off-by: Ishita Sequeira <ishiseq29@gmail.com>
Diffstat (limited to 'registry-scanner/pkg/image/matchfunc_test.go')
-rw-r--r--registry-scanner/pkg/image/matchfunc_test.go27
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]+"))
+ })
+}