-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add unit tests to image-updater pkg/image (#810)
Signed-off-by: Cheng Fang <[email protected]>
- Loading branch information
Showing
5 changed files
with
361 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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))) | ||
} | ||
} |
Oops, something went wrong.