@@ -22,6 +22,26 @@ func Test_ParseImageTags(t *testing.T) {
2222 assert .Equal (t , "jannfis/test-image" , image .GetFullNameWithoutTag ())
2323 })
2424
25+ t .Run ("Single element image name is unmodified" , func (t * testing.T ) {
26+ image := NewFromIdentifier ("test-image" )
27+ assert .Empty (t , image .RegistryURL )
28+ assert .Empty (t , image .ImageAlias )
29+ assert .Equal (t , "test-image" , image .ImageName )
30+ require .Nil (t , image .ImageTag )
31+ assert .Equal (t , "test-image" , image .GetFullNameWithTag ())
32+ assert .Equal (t , "test-image" , image .GetFullNameWithoutTag ())
33+ })
34+
35+ t .Run ("library image name is unmodified" , func (t * testing.T ) {
36+ image := NewFromIdentifier ("library/test-image" )
37+ assert .Empty (t , image .RegistryURL )
38+ assert .Empty (t , image .ImageAlias )
39+ assert .Equal (t , "library/test-image" , image .ImageName )
40+ require .Nil (t , image .ImageTag )
41+ assert .Equal (t , "library/test-image" , image .GetFullNameWithTag ())
42+ assert .Equal (t , "library/test-image" , image .GetFullNameWithoutTag ())
43+ })
44+
2545 t .Run ("Parse valid image name with registry info" , func (t * testing.T ) {
2646 image := NewFromIdentifier ("gcr.io/jannfis/test-image:0.1" )
2747 assert .Equal (t , "gcr.io" , image .RegistryURL )
@@ -33,6 +53,17 @@ func Test_ParseImageTags(t *testing.T) {
3353 assert .Equal (t , "gcr.io/jannfis/test-image" , image .GetFullNameWithoutTag ())
3454 })
3555
56+ t .Run ("Parse valid image name with default registry info" , func (t * testing.T ) {
57+ image := NewFromIdentifier ("docker.io/jannfis/test-image:0.1" )
58+ assert .Equal (t , "docker.io" , image .RegistryURL )
59+ assert .Empty (t , image .ImageAlias )
60+ assert .Equal (t , "jannfis/test-image" , image .ImageName )
61+ require .NotNil (t , image .ImageTag )
62+ assert .Equal (t , "0.1" , image .ImageTag .TagName )
63+ assert .Equal (t , "docker.io/jannfis/test-image:0.1" , image .GetFullNameWithTag ())
64+ assert .Equal (t , "docker.io/jannfis/test-image" , image .GetFullNameWithoutTag ())
65+ })
66+
3667 t .Run ("Parse valid image name with digest tag" , func (t * testing.T ) {
3768 image := NewFromIdentifier ("gcr.io/jannfis/test-image@sha256:abcde" )
3869 assert .Equal (t , "gcr.io" , image .RegistryURL )
@@ -70,6 +101,13 @@ func Test_ParseImageTags(t *testing.T) {
70101 assert .Equal (t , "jannfis/test-image" , image .ImageName )
71102 assert .Nil (t , image .ImageTag )
72103 })
104+ t .Run ("#273 classic-web=registry:5000/classic-web" , func (t * testing.T ) {
105+ image := NewFromIdentifier ("classic-web=registry:5000/classic-web" )
106+ assert .Equal (t , "registry:5000" , image .RegistryURL )
107+ assert .Equal (t , "classic-web" , image .ImageAlias )
108+ assert .Equal (t , "classic-web" , image .ImageName )
109+ assert .Nil (t , image .ImageTag )
110+ })
73111}
74112
75113func Test_ImageToString (t * testing.T ) {
0 commit comments