@@ -96,28 +96,77 @@ func TestImagesRepoOverrideInConfiguration(t *testing.T) {
96
96
}
97
97
98
98
func TestOverrideFunction (t * testing.T ) {
99
- repository := "my.registry"
100
- testCases := []struct {
101
- Input string
102
- Output string
103
- }{
104
- {
105
- Input : "repo/image" ,
106
- Output : "my.registry/repo/image" ,
107
- },
108
- {
109
- Input : "registry.com/repo/image" ,
110
- Output : "my.registry/repo/image" ,
111
- },
112
- {
113
- Input : "image" ,
114
- Output : "my.registry/image" ,
115
- },
116
- }
99
+ t .Run ("overrideRepository without path" , func (t * testing.T ) {
100
+ repository := "my.registry"
101
+ testCases := []struct {
102
+ Input string
103
+ Output string
104
+ }{
105
+ {
106
+ Input : "repo/image" ,
107
+ Output : "my.registry/repo/image" ,
108
+ },
109
+ {
110
+ Input : "registry.com/repo/image" ,
111
+ Output : "my.registry/repo/image" ,
112
+ },
113
+ {
114
+ Input : "image" ,
115
+ Output : "my.registry/image" ,
116
+ },
117
+ }
118
+
119
+ for _ , tc := range testCases {
120
+ assert .Equal (t , tc .Output , overrideRepository (repository , tc .Input ))
121
+ }
122
+ })
123
+ t .Run ("overrideRepository with path" , func (t * testing.T ) {
124
+ repository := "my.registry/foo"
125
+ testCases := []struct {
126
+ Input string
127
+ Output string
128
+ }{
129
+ {
130
+ Input : "repo/image" ,
131
+ Output : "my.registry/foo/repo/image" ,
132
+ },
133
+ {
134
+ Input : "registry.com/repo/image" ,
135
+ Output : "my.registry/foo/repo/image" ,
136
+ },
137
+ {
138
+ Input : "image" ,
139
+ Output : "my.registry/foo/image" ,
140
+ },
141
+ }
142
+ for _ , tc := range testCases {
143
+ assert .Equal (t , tc .Output , overrideRepository (repository , tc .Input ))
144
+ }
145
+ })
146
+ t .Run ("overrideRepository with repo path and double invocation" , func (t * testing.T ) {
147
+ repository := "my.registry/foo"
148
+ testCases := []struct {
149
+ Input string
150
+ Output string
151
+ }{
152
+ {
153
+ Input : "repo/image" ,
154
+ Output : "my.registry/foo/repo/image" ,
155
+ },
156
+ {
157
+ Input : "registry.com/repo/image" ,
158
+ Output : "my.registry/foo/repo/image" ,
159
+ },
160
+ {
161
+ Input : "image" ,
162
+ Output : "my.registry/foo/image" ,
163
+ },
164
+ }
165
+ for _ , tc := range testCases {
166
+ assert .Equal (t , tc .Output , overrideRepository (repository , overrideRepository (repository , tc .Input )))
167
+ }
168
+ })
117
169
118
- for _ , tc := range testCases {
119
- assert .Equal (t , tc .Output , overrideRepository (repository , tc .Input ))
120
- }
121
170
}
122
171
123
172
func TestImageSpec_Validate (t * testing.T ) {
0 commit comments