-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit tests for getImageNameTag function
Signed-off-by: artem198315 <[email protected]>
- Loading branch information
1 parent
624c0ad
commit dbb57ea
Showing
1 changed file
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package helm | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestGetImageNameTag(t *testing.T) { | ||
tests := []struct { | ||
input string | ||
expectedImage string | ||
expectedTag string | ||
}{ | ||
{ | ||
input: "quay.io/metallb/speaker:v0.13.9", | ||
expectedImage: "quay.io/metallb/speaker", | ||
expectedTag: "v0.13.9", | ||
}, | ||
{ | ||
input: "quay.io:5000/metallb/speaker:v0.13.9", | ||
expectedImage: "quay.io:5000/metallb/speaker", | ||
expectedTag: "v0.13.9", | ||
}, | ||
{ | ||
input: "quay.io/metallb/speaker", | ||
expectedImage: "quay.io/metallb/speaker", | ||
expectedTag: "", | ||
}, | ||
{ | ||
input: "quay.io:5000/metallb/speaker", | ||
expectedImage: "quay.io:5000/metallb/speaker", | ||
expectedTag: "", | ||
}, | ||
{ | ||
input: "speaker:v0.13.9", | ||
expectedImage: "speaker", | ||
expectedTag: "v0.13.9", | ||
}, | ||
{ | ||
input: "speaker", | ||
expectedImage: "speaker", | ||
expectedTag: "", | ||
}, | ||
} | ||
|
||
g := NewGomegaWithT(t) | ||
for _, test := range tests { | ||
img, tag := getImageNameTag(test.input) | ||
g.Expect(img).To(Equal(test.expectedImage)) | ||
g.Expect(tag).To(Equal(test.expectedTag)) | ||
} | ||
} |