Skip to content

Commit

Permalink
add unit tests for getImageNameTag function
Browse files Browse the repository at this point in the history
Signed-off-by: artem198315 <[email protected]>
  • Loading branch information
artem198315 authored and oribon committed Aug 7, 2023
1 parent 624c0ad commit dbb57ea
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions pkg/helm/config_test.go
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))
}
}

0 comments on commit dbb57ea

Please sign in to comment.