github.com/kvattikuti/drone@v0.2.1-0.20140603034306-d400229a327a/pkg/build/util_test.go (about) 1 package build 2 3 import "testing" 4 5 func TestParseImageName(t *testing.T) { 6 images := []struct { 7 owner string 8 name string 9 tag string 10 cname string 11 }{ 12 // full image name with all 3 sections present 13 {"johnsmith", "redis", "2.8", "johnsmith/redis:2.8"}, 14 // image name with no tag specified 15 {"johnsmith", "redis", "latest", "johnsmith/redis"}, 16 // image name with no owner specified 17 {"bradrydzewski", "redis", "2.8", "redis:2.8"}, 18 // image name with ownly name specified 19 {"bradrydzewski", "redis2", "latest", "redis2"}, 20 // image name that is a known alias 21 {"relateiq", "cassandra", "latest", "cassandra"}, 22 } 23 24 for _, img := range images { 25 owner, name, tag := parseImageName(img.cname) 26 if owner != img.owner { 27 t.Errorf("Expected image %s with owner %s, got %s", img.cname, img.owner, owner) 28 } 29 if name != img.name { 30 t.Errorf("Expected image %s with name %s, got %s", img.cname, img.name, name) 31 } 32 if tag != img.tag { 33 t.Errorf("Expected image %s with tag %s, got %s", img.cname, img.tag, tag) 34 } 35 } 36 }