-
Notifications
You must be signed in to change notification settings - Fork 16
/
admin_test.go
43 lines (38 loc) · 880 Bytes
/
admin_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
package admin
import (
"testing"
)
func TestParseTagSimple(T *testing.T) {
res, _ := parseTag("key=value only_key")
if key, ok := res["key"]; ok {
if key != "value" {
T.Error("Expected 'key' to be 'value'")
}
} else {
T.Error("Expected 'key' to be found.")
}
if key, ok := res["only_key"]; ok {
if key != "" {
T.Error("Expected 'only_key' to be empty")
}
} else {
T.Error("Expected 'only_key' to be found.")
}
}
func TestParseTagMulti(T *testing.T) {
res, _ := parseTag("key=value another=pair and='another one'")
if key, ok := res["another"]; ok {
if key != "pair" {
T.Error("Expected 'another' to be 'pair'")
}
} else {
T.Error("Expected 'another' to be found.")
}
if key, ok := res["and"]; ok {
if key != "another one" {
T.Error("Expected 'and' to be 'another one'")
}
} else {
T.Error("Expected 'and' to be found.")
}
}