forked from adlio/trello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checklist_test.go
93 lines (75 loc) · 2.56 KB
/
checklist_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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package trello
import (
"testing"
)
func TestCreateChecklist(t *testing.T) {
c := testClient()
c.BaseURL = mockResponse("checklists", "checklist-create.json").URL
card := Card{
Name: "Test Card Create",
IDList: "57f03a06b5ff33a63c8be316",
ID: "5c41028905a859019e323bc9",
IDBoard: "5c41027ca9c378795b5a5036",
}
checklistName := "hello"
cl, err := c.CreateChecklist(&card, checklistName, Arguments{"pos": "33"})
if err != nil {
t.Error(err)
}
if card.Checklists[0].ID != "5cc064cb72fbdb774ff22bac" {
t.Errorf("Expected checklist to pick up an ID. Instead got '%s'.", card.ID)
}
if cl.ID != "5cc064cb72fbdb774ff22bac" {
t.Errorf("Expected checklist to pick up an ID. Instead got '%s'.", cl.ID)
}
if cl.IDCard != card.ID {
t.Errorf("Expected checklist to pick up card ID. Instead got '%s'.", cl.IDCard)
}
if cl.IDBoard != card.IDBoard {
t.Errorf("Expected checklist to pick up board ID. Instead got '%s'.", cl.IDBoard)
}
if card.IDBoard != "5c41027ca9c378795b5a5036" {
t.Errorf("Expected card to keep its IDBOard. Instead got '%s'.", card.IDBoard)
}
if cl.Name != checklistName {
t.Errorf("Expected checklist name to be set. Instead got '%s'.", cl.Name)
}
if cl.client == nil {
t.Errorf("Expected checklist to pick up a client. Instead got nil.")
}
if cl.Pos != 33 {
t.Errorf("Expected the returned checklist to pick up a position. Instead got '%v'.", cl.Pos)
}
}
func TestCreateCheckItem(t *testing.T) {
c := testClient()
c.BaseURL = mockResponse("checklists", "checkitem-create.json").URL
cl := Checklist{
Name: "SomeName",
ID: "5cc05fc2a44eed7872662d1b",
client: c,
}
checkItemName := "hello2"
item, err := cl.CreateCheckItem(checkItemName, Arguments{"pos": "35", "checked": "true"})
if err != nil {
t.Error(err)
}
if item.IDChecklist != "5cc05fc2a44eed7872662d1b" {
t.Errorf("Expected checkitem to pick up checklist ID. Instead got '%s'.", item.IDChecklist)
}
if item.ID != "5cc05fddf0d64d1c89e2a3b5" {
t.Errorf("Expected checkitem to pick up an ID. Instead got '%s'.", item.ID)
}
if len(cl.CheckItems) != 1 {
t.Errorf("Expected checklist to pick up the created checkitem. Instead got '%v'.", len(cl.CheckItems))
}
if cl.CheckItems[0] != *item {
t.Errorf("Expected the returned item and the checkitem inside the checklist to be equal.\n got: %#v\nwant: %#v", cl.CheckItems[0], *item)
}
if item.Pos != 35 {
t.Errorf("Expected the returned item to pick up a position. Instead got '%v'.", item.Pos)
}
if item.State != "complete" {
t.Errorf("Expected checked to be set. Instead got '%s'.", item.State)
}
}