mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-11-25 22:12:08 +02:00
Support state filter for GetAllSprints call
* creates a GetAllSprintsOptions structure * adds a new GetAllSprintsWithOptions method to accept an int boardID and new options structure * adds filtering functionality to GetAllSprintsWithOptions method * adds SprintsList type for handling pagination results data from GetAllSprints request * updates tests
This commit is contained in:
@@ -184,3 +184,35 @@ func TestBoardService_GetAllSprints(t *testing.T) {
|
||||
t.Errorf("Expected 4 transitions. Got %d", len(sprints))
|
||||
}
|
||||
}
|
||||
|
||||
func TestBoardService_GetAllSprintsWithOptions(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
testAPIEndpoint := "/rest/agile/1.0/board/123/sprint"
|
||||
|
||||
raw, err := ioutil.ReadFile("./mocks/sprints_filtered.json")
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
}
|
||||
|
||||
testMux.HandleFunc(testAPIEndpoint, func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testRequestURL(t, r, testAPIEndpoint)
|
||||
fmt.Fprint(w, string(raw))
|
||||
})
|
||||
|
||||
sprints, _, err := testClient.Board.GetAllSprintsWithOptions(123, &GetAllSprintsOptions{State: "active,future"})
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Got error: %v", err)
|
||||
}
|
||||
|
||||
if sprints == nil {
|
||||
t.Error("Expected sprint list. Got nil.")
|
||||
}
|
||||
|
||||
if len(sprints.Values) != 1 {
|
||||
t.Errorf("Expected 1 transition. Got %d", len(sprints.Values))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user