From 7e0dd0ed3933aba3e2a8234202edf0ad93c63050 Mon Sep 17 00:00:00 2001 From: Dimitris Stafylarakis Date: Sun, 12 May 2019 10:54:48 +0200 Subject: [PATCH] Fix board request parameter The BoardListOption field BoardType was incorrectly mapped to boardType instead of type. This commit fixes it. A generic test helper function (testRequestParams) is added in order to improve the effectiveness of the unit test. Fixes #213 --- board.go | 2 +- board_test.go | 1 + jira_test.go | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/board.go b/board.go index 091797d4..a691672c 100644 --- a/board.go +++ b/board.go @@ -35,7 +35,7 @@ type Board struct { type BoardListOptions struct { // BoardType filters results to boards of the specified type. // Valid values: scrum, kanban. - BoardType string `url:"boardType,omitempty"` + BoardType string `url:"type,omitempty"` // Name filters results to boards that match or partially match the specified name. Name string `url:"name,omitempty"` // ProjectKeyOrID filters results to boards that are relevant to a project. diff --git a/board_test.go b/board_test.go index 192caf0e..425027b3 100644 --- a/board_test.go +++ b/board_test.go @@ -44,6 +44,7 @@ func TestBoardService_GetAllBoards_WithFilter(t *testing.T) { testMux.HandleFunc(testAPIEdpoint, func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testRequestURL(t, r, testAPIEdpoint) + testRequestParams(t, r, map[string]string{"type": "scrum", "name": "Test", "startAt": "1", "maxResults": "10", "projectKeyOrId": "TE"}) fmt.Fprint(w, string(raw)) }) diff --git a/jira_test.go b/jira_test.go index a731fc57..d02686f4 100644 --- a/jira_test.go +++ b/jira_test.go @@ -58,6 +58,22 @@ func testRequestURL(t *testing.T, r *http.Request, want string) { } } +func testRequestParams(t *testing.T, r *http.Request, want map[string]string) { + params := r.URL.Query() + + if len(params) != len(want) { + t.Errorf("Request params: %d, want %d", len(params), len(want)) + } + + for key, val := range want { + if got := params.Get(key); val != got { + t.Errorf("Request params: %s, want %s", got, val) + } + + } + +} + func TestNewClient_WrongUrl(t *testing.T) { c, err := NewClient(nil, "://issues.apache.org/jira/")