1
13
14 package driver
15
16 import (
17 "reflect"
18 "testing"
19 )
20
21 func TestGetSystemLabel(t *testing.T) {
22 if output := GetSystemLabels(); !reflect.DeepEqual(systemLabels, output) {
23 t.Errorf("Expected {%v}, got {%v}", systemLabels, output)
24 }
25 }
26
27 func TestIsSystemLabel(t *testing.T) {
28 tests := map[string]bool{
29 "name": true,
30 "owner": true,
31 "test": false,
32 "NaMe": false,
33 }
34 for label, result := range tests {
35 if output := isSystemLabel(label); output != result {
36 t.Errorf("Output %t not equal to expected %t", output, result)
37 }
38 }
39 }
40
41 func TestFilterSystemLabels(t *testing.T) {
42 var tests = [][2]map[string]string{
43 {nil, map[string]string{}},
44 {map[string]string{}, map[string]string{}},
45 {map[string]string{
46 "name": "name",
47 "owner": "owner",
48 "status": "status",
49 "version": "version",
50 "createdAt": "createdAt",
51 "modifiedAt": "modifiedAt",
52 }, map[string]string{}},
53 {map[string]string{
54 "StaTus": "status",
55 "name": "name",
56 "owner": "owner",
57 "key": "value",
58 }, map[string]string{
59 "StaTus": "status",
60 "key": "value",
61 }},
62 {map[string]string{
63 "key1": "value1",
64 "key2": "value2",
65 }, map[string]string{
66 "key1": "value1",
67 "key2": "value2",
68 }},
69 }
70 for _, test := range tests {
71 if output := filterSystemLabels(test[0]); !reflect.DeepEqual(test[1], output) {
72 t.Errorf("Expected {%v}, got {%v}", test[1], output)
73 }
74 }
75 }
76
77 func TestContainsSystemLabels(t *testing.T) {
78 var tests = []struct {
79 input map[string]string
80 output bool
81 }{
82 {nil, false},
83 {map[string]string{}, false},
84 {map[string]string{
85 "name": "name",
86 "owner": "owner",
87 "status": "status",
88 "version": "version",
89 "createdAt": "createdAt",
90 "modifiedAt": "modifiedAt",
91 }, true},
92 {map[string]string{
93 "StaTus": "status",
94 "name": "name",
95 "owner": "owner",
96 "key": "value",
97 }, true},
98 {map[string]string{
99 "key1": "value1",
100 "key2": "value2",
101 }, false},
102 }
103 for _, test := range tests {
104 if output := ContainsSystemLabels(test.input); !reflect.DeepEqual(test.output, output) {
105 t.Errorf("Expected {%v}, got {%v}", test.output, output)
106 }
107 }
108 }
109
View as plain text