summaryrefslogtreecommitdiff
path: root/registry-scanner/pkg/image/kustomize_test.go
blob: 98dede9cad307795bd5ba5ae0f470558cc6ab83d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package image

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func Test_KustomizeImages_Find(t *testing.T) {
	images := KustomizeImages{
		"a/b:1.0",
		"a/b@sha256:aabb",
		"a/b:latest@sha256:aabb",
		"x/y=busybox",
		"x/y=foo.bar/a/c:0.23",
	}
	for _, image := range images {
		assert.True(t, images.Find(image) >= 0)
	}
	for _, image := range []string{"a/b:2", "x/y=foo.bar"} {
		assert.True(t, images.Find(KustomizeImage(image)) >= 0)
	}
	for _, image := range []string{"a/b", "x", "x/y"} {
		assert.Equal(t, -1, images.Find(KustomizeImage(image)))
	}
}