54 lines
976 B
Go
54 lines
976 B
Go
package watchers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestParseImageName(t *testing.T) {
|
|
testCases := []struct {
|
|
imageName string
|
|
expect string
|
|
}{
|
|
{
|
|
imageName: "",
|
|
expect: "",
|
|
},
|
|
{
|
|
imageName: "toto",
|
|
expect: "localenv-toto",
|
|
},
|
|
{
|
|
imageName: "company/my-microservice:latest",
|
|
expect: "localenv-my-microservice",
|
|
},
|
|
{
|
|
imageName: "localenv-nginx",
|
|
expect: "localenv-nginx",
|
|
},
|
|
{
|
|
imageName: "localenv-nginx:latest",
|
|
expect: "localenv-nginx",
|
|
},
|
|
{
|
|
imageName: "mailhog/mailhog:latest",
|
|
expect: "localenv-mailhog",
|
|
},
|
|
{
|
|
imageName: "company/my-super-ms",
|
|
expect: "localenv-my-super-ms",
|
|
},
|
|
{
|
|
imageName: "registry.mycompany.com/company/test/build-images/microservice-base",
|
|
expect: "localenv-microservice-base",
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
imageName := parseImageName(tc.imageName)
|
|
|
|
assert.Equal(t, tc.expect, imageName)
|
|
}
|
|
}
|