forked from adlio/trello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action_test.go
114 lines (104 loc) · 2.56 KB
/
action_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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright © 2016 Aaron Longwell
//
// Use of this source code is governed by an MIT licese.
// Details in the LICENSE file.
package trello
import (
"testing"
)
func TestGetActionsOnBoard(t *testing.T) {
board := testBoard(t)
board.client.BaseURL = mockResponse("actions", "board-actions-api-example.json").URL
actions, err := board.GetActions(Defaults())
if err != nil {
t.Fatal(err)
}
if len(actions) != 4 {
t.Errorf("Expected 4 actions, got %d", len(actions))
}
}
func TestGetActionsOnList(t *testing.T) {
list := testList(t)
list.client.BaseURL = mockResponse("actions", "list-actions-api-example.json").URL
actions, err := list.GetActions(Defaults())
if err != nil {
t.Fatal(err)
}
if len(actions) != 2 {
t.Errorf("Expected 2 actions, got %d", len(actions))
}
}
func TestGetActionsOnCard(t *testing.T) {
card := testCard(t)
card.client.BaseURL = mockResponse("actions", "card-actions-api-example.json").URL
actions, err := card.GetActions(Defaults())
if err != nil {
t.Fatal(err)
}
if len(actions) != 50 {
t.Errorf("Expected 50 actions, got %d", len(actions))
}
}
func TestListAfterActionOnUpdateCard(t *testing.T) {
a := &Action{
Type: "updateCard",
Data: &ActionData{
ListBefore: &List{Name: "Before"},
ListAfter: &List{Name: "After"},
},
}
l := ListAfterAction(a)
if l.Name != "After" {
t.Errorf("Incorrect List name '%s'", l.Name)
}
}
func TestListAfterActionOnArchive(t *testing.T) {
a := &Action{
Type: "updateCard",
Data: &ActionData{
List: &List{Name: "SameList"},
Board: &Board{},
Card: &ActionDataCard{Closed: true},
Old: &ActionDataCard{Closed: false},
},
}
l := ListAfterAction(a)
if l != nil {
t.Error("ListAfterAction() should be nil after an archive.")
}
}
func TestListAfterActionOnUnarchive(t *testing.T) {
a := &Action{
Type: "updateCard",
Data: &ActionData{
List: &List{Name: "SameList"},
Board: &Board{},
Card: &ActionDataCard{Closed: false},
Old: &ActionDataCard{Closed: true},
},
}
l := ListAfterAction(a)
if l == nil {
t.Error("ListAfterAction() should not be nil after an unarchive.")
}
if l.Name != "SameList" {
t.Errorf("Incorrect List name '%s'.", l.Name)
}
}
func TestListAfterActionOnCopyCard(t *testing.T) {
a := &Action{
Type: "copyCard",
Data: &ActionData{
List: &List{Name: "FirstList"},
Board: &Board{},
Card: &ActionDataCard{Closed: false},
},
}
l := ListAfterAction(a)
if l == nil {
t.Error("ListAfterAction() should not be nil after a copy")
}
if l.Name != "FirstList" {
t.Errorf("Incorrect List name '%s'.", l.Name)
}
}