-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathhelpers_test.go
76 lines (70 loc) · 1.46 KB
/
helpers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package filesystems
import (
"reflect"
"testing"
)
func TestParseProperties(t *testing.T) {
testData := []struct {
name string
input string
expected map[string]string
expectError bool
}{
{
name: "no items",
input: "",
expected: map[string]string{},
expectError: false,
},
{
name: "invalid item",
input: "hello",
expectError: true,
},
{
name: "single item",
input: "hello=world",
expected: map[string]string{
"hello": "world",
},
},
{
name: "single-item-base64",
input: "hello=aGVsbG8=",
expected: map[string]string{
"hello": "aGVsbG8=",
},
expectError: false,
},
{
name: "single-item-base64-multipleequals",
input: "hello=d29uZGVybGFuZA==",
expected: map[string]string{
"hello": "d29uZGVybGFuZA==",
},
expectError: false,
},
{
name: "multiple-items-base64",
input: "hello=d29uZGVybGFuZA==,private=ZXll",
expected: map[string]string{
"hello": "d29uZGVybGFuZA==",
"private": "ZXll",
},
expectError: false,
},
}
for _, testCase := range testData {
t.Logf("[DEBUG] Test %q", testCase.name)
actual, err := parseProperties(testCase.input)
if err != nil {
if testCase.expectError {
continue
}
t.Fatalf("[DEBUG] Didn't expect an error but got %s", err)
}
if !reflect.DeepEqual(testCase.expected, *actual) {
t.Fatalf("Expected %+v but got %+v", testCase.expected, *actual)
}
}
}