-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcustomfield_test.go
71 lines (64 loc) · 1.76 KB
/
customfield_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
package yext
import (
"fmt"
"testing"
)
func TestSetMultiOptionId(t *testing.T) {
a := MultiOption([]string{"a", "b", "c"})
a.SetOptionId("d")
b := MultiOption([]string{"a", "b", "c", "d"})
stringA, stringB := fmt.Sprint(a), fmt.Sprint(b)
if stringA != stringB {
t.Errorf("expected %v was %v", b, a)
}
}
func TestUnsetMultiOptionId(t *testing.T) {
a := MultiOption([]string{"a", "b", "c"})
b := MultiOption([]string{"a", "c"})
a.UnsetOptionId("b")
stringA, stringB := fmt.Sprint(a), fmt.Sprint(b)
if stringA != stringB {
t.Errorf("expected %v was %v", b, a)
}
}
func TestIsMultiOptionIdSet(t *testing.T) {
a := MultiOption([]string{"a", "b", "c"})
if !a.IsOptionIdSet("a") {
t.Errorf("expected true but was false for 'a' in '%s' ", a)
}
if a.IsOptionIdSet("d") {
t.Errorf("expected false but was true for 'd' in '%s'", a)
}
}
func TestSetSingleOptionId(t *testing.T) {
a := SingleOption("a")
b := SingleOption("b")
a.SetOptionId("b")
stringA, stringB := fmt.Sprint(a), fmt.Sprint(b)
if stringA != stringB {
t.Errorf("expected '%v' was '%v'", b, a)
}
}
func TestUnsetSingleOptionId(t *testing.T) {
a := SingleOption("a")
b := SingleOption("a")
a.UnsetOptionId("d") // not currently set
stringA, stringB := fmt.Sprint(a), fmt.Sprint(b)
if stringA != stringB {
t.Errorf("unset not the same: expected '%v' was '%v'", b, a)
}
a.UnsetOptionId("a")
stringA, stringB = fmt.Sprint(a), ""
if stringA != stringB {
t.Errorf("unset not the same: expected '%v' was '%v'", b, a)
}
}
func TestIsSingleOptionIdSet(t *testing.T) {
a := SingleOption("a")
if !a.IsOptionIdSet("a") {
t.Errorf("expected true but was false for 'a' being set on '%s'", a)
}
if a.IsOptionIdSet("d") {
t.Errorf("expected false but was true for 'd' being set on '%s'", a)
}
}