38 lines
801 B
Go
38 lines
801 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func Test_buildRepo(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
registry string
|
|
repo string
|
|
want string
|
|
}{
|
|
{
|
|
name: "dockerhub",
|
|
repo: "golang",
|
|
want: "golang",
|
|
},
|
|
{
|
|
name: "internal",
|
|
registry: "artifactory.example.com",
|
|
repo: "service",
|
|
want: "artifactory.example.com/service",
|
|
},
|
|
{
|
|
name: "backward_compatibility",
|
|
registry: "artifactory.example.com",
|
|
repo: "artifactory.example.com/service",
|
|
want: "artifactory.example.com/service",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := buildRepo(tt.registry, tt.repo, true); got != tt.want {
|
|
t.Errorf("buildRepo(%q, %q) = %v, want %v", tt.registry, tt.repo, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|