Skip to content

Commit

Permalink
Merge e6abb08 into e4cc07c
Browse files Browse the repository at this point in the history
  • Loading branch information
ogidow committed Feb 18, 2019
2 parents e4cc07c + e6abb08 commit b87c0e1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions board.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ func (c *Client) GetBoard(boardID string, args Arguments) (board *Board, err err
return
}

func (c *Client) GetMyBoards( args Arguments) (boards []*Board, err error) {
path := "members/me/boards"
err = c.Get(path, args, &boards)
for i := range boards {
boards[i].client = c
}
return
}

func (m *Member) GetBoards(args Arguments) (boards []*Board, err error) {
path := fmt.Sprintf("members/%s/boards", m.ID)
err = m.client.Get(path, args, &boards)
Expand Down
22 changes: 22 additions & 0 deletions board_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ func TestGetBoards(t *testing.T) {

}

func TestGetMyBoards(t *testing.T) {
c := testClient()

c.BaseURL = mockResponse("boards", "member-boards-example.json").URL
boards, err := c.GetMyBoards(Defaults())
if err != nil {
t.Fatal(err)
}

if len(boards) != 2 {
t.Errorf("Expected 2 boards. Got %d", len(boards))
}

if boards[0].Name != "Example Board" {
t.Errorf("Name of first board incorrect. Got: '%s'", boards[0].Name)
}

if boards[1].Name != "Public Board" {
t.Errorf("Name of second board incorrect. Got: '%s'", boards[1].Name)
}
}

func TestGetUnauthorizedBoard(t *testing.T) {
c := testClient()
c.BaseURL = mockErrorResponse(401).URL
Expand Down

0 comments on commit b87c0e1

Please sign in to comment.