Skip to content
This repository was archived by the owner on Jun 23, 2020. It is now read-only.

Commit 2179679

Browse files
committed
add more tests
1 parent 0017a03 commit 2179679

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

pkg/provisioner/block/block_test.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,21 @@ func TestGetTags(t *testing.T) {
190190
expectedDefinedTags map[string]map[string]interface{}
191191
expectedFreeformTags map[string]string
192192
}{
193+
"no default or annotation tags": {
194+
setup: func() {
195+
os.Setenv(defaultTagsEnvVar, "")
196+
},
197+
annotations: map[string]string{},
198+
expectedDefinedTags: map[string]map[string]interface{}{},
199+
expectedFreeformTags: map[string]string{},
200+
},
193201
"valid tags only default": {
194202
setup: func() {
195-
os.Setenv(defaultTagsEnvVar, "namespace1.default=test,default=test")
203+
os.Setenv(defaultTagsEnvVar, "defaultnamespace.default=test,default=test")
196204
},
197205
annotations: map[string]string{},
198206
expectedDefinedTags: map[string]map[string]interface{}{
199-
"namespace1": map[string]interface{}{
207+
"defaultnamespace": map[string]interface{}{
200208
"default": "test",
201209
},
202210
},
@@ -227,6 +235,22 @@ func TestGetTags(t *testing.T) {
227235
"default": "test",
228236
},
229237
},
238+
"override defaults with annotation": {
239+
setup: func() {
240+
os.Setenv(defaultTagsEnvVar, "namespace1.default=test,default=test")
241+
},
242+
annotations: map[string]string{
243+
ociTagAnnotation: "namespace1.default=foo,default=bar",
244+
},
245+
expectedDefinedTags: map[string]map[string]interface{}{
246+
"namespace1": map[string]interface{}{
247+
"default": "foo",
248+
},
249+
},
250+
expectedFreeformTags: map[string]string{
251+
"default": "bar",
252+
},
253+
},
230254
}
231255

232256
for name, tc := range testCases {

0 commit comments

Comments
 (0)