forked from adlio/trello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-fields_test.go
55 lines (43 loc) · 1.34 KB
/
custom-fields_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
// Copyright © 2018 Miguel Ángel Ajo
//
// Use of this source code is governed by an MIT licese.
// Details in the LICENSE file.
package trello
import (
"testing"
)
func TestGetCustomField(t *testing.T) {
customField := testCustomField(t)
if customField.Name != "Priority" {
t.Errorf("Name incorrect. Got '%s'", customField.Name)
}
}
func TestGetCustomFieldsOnBoard(t *testing.T) {
customFields := testBoardCustomFields(t)
if len(customFields) != 2 {
t.Errorf("Expected 2 custom fields, got %d", len(customFields))
}
for _, cf := range customFields {
if len(cf.Options) != 2 {
t.Errorf("Expected 2 options on custom field %s, got %d", cf.Name, len(cf.Options))
}
}
}
func testBoardCustomFields(t *testing.T) []*CustomField {
board := testBoard(t)
board.client.BaseURL = mockResponse("boards", "4ed7e27fe6abb2517a21383d", "customFields.json").URL
customFields, err := board.GetCustomFields(Defaults())
if err != nil {
t.Fatal(err)
}
return customFields
}
func testCustomField(t *testing.T) *CustomField {
c := testClient()
c.BaseURL = mockResponse("customFields", "api-example.json").URL
customField, err := c.GetCustomField("5a98670bd6afbd6de1c8c360", Defaults())
if err != nil {
t.Fatal(err)
}
return customField
}