-
Notifications
You must be signed in to change notification settings - Fork 0
/
value_query_string_test.go
48 lines (34 loc) · 1.14 KB
/
value_query_string_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
package env
import "testing"
func TestQueryStringValue_Set(t *testing.T) {
p := new(map[string]string)
val := newQueryStringValue(map[string]string{"key": "value"}, p)
val.Set("key2=value2") // nolint: errcheck
if _, exists := (*val)["key"]; exists {
t.Error("query string map should be clear of default value upon set")
}
}
func TestQueryStringValue_SetEmpty(t *testing.T) {
p := new(map[string]string)
val := newQueryStringValue(map[string]string{"key": "value"}, p)
val.Set("") // nolint: errcheck
if _, exists := (*val)["key"]; exists {
t.Error("query string map should be clear of default value upon set (even if empty)")
}
}
func TestQueryStringValue_SetEmptyValue(t *testing.T) {
tests := map[string]string{
"with equal sign": "key=",
"without equal sign": "key=",
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
p := new(map[string]string)
val := newQueryStringValue(map[string]string{}, p)
val.Set(test) // nolint: errcheck
if value, exists := (*val)["key"]; !exists || value != "" {
t.Error("query string map should have an empty value element under key \"key\"")
}
})
}
}