drone-kaniko/cmd/kaniko-docker/main_test.go

38 lines
795 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); got != tt.want {
t.Errorf("buildRepo(%q, %q) = %v, want %v", tt.registry, tt.repo, got, tt.want)
}
})
}
}