Skip to content

Commit

Permalink
Merge 7a7d198 into 4701389
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasper authored Mar 20, 2018
2 parents 4701389 + 7a7d198 commit 481a37f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
5 changes: 4 additions & 1 deletion card.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ type Card struct {
Attachments []*Attachment `json:"attachments,omitempty"`

// Labels
Labels []*Label `json:"labels,omitempty"`
IDLabels []string `json:idLabels,omitempty"`
Labels []*Label `json:"labels,omitempty"`
}

func (c *Card) CreatedAt() time.Time {
Expand Down Expand Up @@ -121,6 +122,7 @@ func (c *Client) CreateCard(card *Card, extraArgs Arguments) error {
"pos": strconv.FormatFloat(card.Pos, 'g', -1, 64),
"idList": card.IDList,
"idMembers": strings.Join(card.IDMembers, ","),
"idLabels": strings.Join(card.IDLabels, ","),
}
if card.Due != nil {
args["due"] = card.Due.Format(time.RFC3339)
Expand All @@ -142,6 +144,7 @@ func (l *List) AddCard(card *Card, extraArgs Arguments) error {
"name": card.Name,
"desc": card.Desc,
"idMembers": strings.Join(card.IDMembers, ","),
"idLabels": strings.Join(card.IDLabels, ","),
}
if card.Due != nil {
args["due"] = card.Due.Format(time.RFC3339)
Expand Down
24 changes: 17 additions & 7 deletions card_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ func TestCreateCard(t *testing.T) {
dueDate := time.Now().AddDate(0, 0, 3)

card := Card{
Name: "Test Card Create",
Desc: "What its about",
Due: &dueDate,
IDList: "57f03a06b5ff33a63c8be316",
Name: "Test Card Create",
Desc: "What its about",
Due: &dueDate,
IDList: "57f03a06b5ff33a63c8be316",
IDLabels: []string{"label1", "label2"},
}

err := c.CreateCard(&card, Arguments{"pos": "top"})
Expand All @@ -94,6 +95,10 @@ func TestCreateCard(t *testing.T) {
if card.ID != "57f5183c691585658d408681" {
t.Errorf("Expected card to pick up an ID. Instead got '%s'.", card.ID)
}

if len(card.Labels) < 2 {
t.Errorf("Expected card to be assigned two labels. Instead got '%v'.", card.Labels)
}
}

func TestAddCardToList(t *testing.T) {
Expand All @@ -102,9 +107,10 @@ func TestAddCardToList(t *testing.T) {
dueDate := time.Now().AddDate(0, 0, 1)

card := Card{
Name: "Test Card POSTed to List",
Desc: "This is its description.",
Due: &dueDate,
Name: "Test Card POSTed to List",
Desc: "This is its description.",
Due: &dueDate,
IDLabels: []string{"label1", "label2"},
}

err := l.AddCard(&card, Arguments{"pos": "bottom"})
Expand All @@ -123,6 +129,10 @@ func TestAddCardToList(t *testing.T) {
if card.ID != "57f5118667db8839dab68698" {
t.Errorf("Expected card to pick up an ID. Instead got '%s'.", card.ID)
}

if len(card.Labels) < 2 {
t.Errorf("Expected card to be assigned two labels. Instead got '%v'.", card.Labels)
}
}

func TestCopyCardToList(t *testing.T) {
Expand Down
19 changes: 17 additions & 2 deletions testdata/cards/card-create.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,28 @@
"email": null,
"idBoard": "57f039fbc0f98772398d289d",
"idChecklists": [],
"idLabels": [],
"idLabels": ["label1", "label2"],
"idList": "57f03a06b5ff33a63c8be316",
"idMembers": [],
"idShort": 9,
"idAttachmentCover": null,
"manualCoverAttachment": false,
"labels": [],
"labels": [
{
"id": "akjbwerkljj",
"idBoard": "kjlbaweti",
"name": "Overdue",
"color": "red",
"uses": 3
},
{
"id": "akjbwerkljj",
"idBoard": "kjlbaweti",
"name": "Complete",
"color": "green",
"uses": 6
}
],
"name": "Test Card Create",
"pos": 8192,
"shortUrl": "https://trello.com/c/j9UEXfyh",
Expand Down
19 changes: 17 additions & 2 deletions testdata/cards/card-posted-to-bottom-of-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,28 @@
"email": null,
"idBoard": "57f039fbc0f98772398d289d",
"idChecklists": [],
"idLabels": [],
"idLabels": ["label1", "label2"],
"idList": "57f03a06b5ff33a63c8be316",
"idMembers": [],
"idShort": 8,
"idAttachmentCover": null,
"manualCoverAttachment": false,
"labels": [],
"labels": [
{
"id": "akjbwerkljj",
"idBoard": "kjlbaweti",
"name": "Overdue",
"color": "red",
"uses": 3
},
{
"id": "akjbwerkljj",
"idBoard": "kjlbaweti",
"name": "Complete",
"color": "green",
"uses": 6
}
],
"name": "Test Card POSTed to list",
"pos": 32768,
"shortUrl": "https://trello.com/c/Nz9LWf8C",
Expand Down

0 comments on commit 481a37f

Please sign in to comment.