-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact_test.go
46 lines (44 loc) · 1.07 KB
/
contact_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
package contacts
import (
"testing"
"time"
)
func TestAttributeChanges(t *testing.T) {
c := &Contact{
ID: "id",
Name: "Name",
First: "First",
Last: "Last",
Birthday: time.Now(),
Email: []string{"Email1", "Email2"},
Phone: []string{"Phone", "Phone Alt"},
Labels: []string{"Label", "Another Label"},
}
vals := c.attributeValues()
if len(vals) != 7 {
t.Errorf("vals was not expected length: %+v", vals)
}
c1 := &Contact{
ID: "id2",
Name: "Name2",
Last: "Last",
Birthday: time.Now(),
Email: []string{"Email1"},
Phone: []string{"Phone", "Phone Alt", "Phone 3"},
Labels: []string{"Label", "Another Label"},
}
ch := c.changes(c1)
t.Logf("changes: %+v", ch)
if len(ch["add"]) != 0 {
t.Errorf("wrong number of adds: %+v", ch["add"])
}
if len(ch["delete"]) != 1 {
t.Errorf("wrong number of deletes: %+v", ch["delete"])
}
if len(ch["replace"]) != 2 {
t.Errorf("wrong number of replaces: %+v", ch["replace"])
}
if len(ch["modify"]) != 1 {
t.Errorf("wrong number of modifies: %+v", ch["modify"])
}
}