1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-28 08:39:03 +02:00
go-jira/board_test.go

68 lines
1.4 KiB
Go
Raw Normal View History

package jira
import (
"fmt"
"io/ioutil"
"net/http"
"testing"
)
func TestBoardsGetAll(t *testing.T) {
setup()
defer teardown()
testAPIEdpoint := "/rest/agile/1.0/board"
raw, err := ioutil.ReadFile("./mocks/all_boards.json")
if err != nil {
t.Error(err.Error())
}
testMux.HandleFunc(testAPIEdpoint, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testRequestURL(t, r, testAPIEdpoint)
fmt.Fprint(w, string(raw))
})
projects, _, err := testClient.Board.GetList(nil)
if projects == nil {
t.Error("Expected boards list. Boards list is nil")
}
if err != nil {
t.Errorf("Error given: %s", err)
}
}
// Test with params
func TestBoardsGetFiltered(t *testing.T) {
setup()
defer teardown()
testAPIEdpoint := "/rest/agile/1.0/board"
raw, err := ioutil.ReadFile("./mocks/all_boards_filtered.json")
if err != nil {
t.Error(err.Error())
}
testMux.HandleFunc(testAPIEdpoint, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testRequestURL(t, r, testAPIEdpoint)
fmt.Fprint(w, string(raw))
})
boardsListOptions := BoardListOptions {
BoardType: "scrum",
Name: "Test",
ProjectKeyOrId: "TE",
StartAt: 1,
MaxResults: 10,
}
projects, _, err := testClient.Board.GetList(&boardsListOptions)
if projects == nil {
t.Error("Expected boards list. Boards list is nil")
}
if err != nil {
t.Errorf("Error given: %s", err)
}
}