mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-02-03 13:11:49 +02:00
add delete board with tests + go fmt
This commit is contained in:
parent
7d8addc179
commit
c66a9e0e77
20
board.go
20
board.go
@ -71,8 +71,8 @@ func (s *BoardService) GetList(opt *BoardListOptions) (*BoardsList, *http.Respon
|
||||
}
|
||||
|
||||
// Returns the board for the given board Id. This board will only be returned if the user has permission to view it.
|
||||
func (s *BoardService) Get(boardID string) (*Board, *http.Response, error) {
|
||||
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%s", boardID)
|
||||
func (s *BoardService) Get(boardID int) (*Board, *http.Response, error) {
|
||||
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%v", boardID)
|
||||
req, err := s.client.NewRequest("GET", apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@ -92,7 +92,7 @@ func (s *BoardService) Get(boardID string) (*Board, *http.Response, error) {
|
||||
// filterId - Id of a filter that the user has permissions to view.
|
||||
// Note, if the user does not have the 'Create shared objects' permission and tries to create a shared board, a private
|
||||
// board will be created instead (remember that board sharing depends on the filter sharing).
|
||||
|
||||
//
|
||||
// JIRA API docs: https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-createBoard
|
||||
func (s *BoardService) Create(board *Board) (*Board, *http.Response, error) {
|
||||
|
||||
@ -109,3 +109,17 @@ func (s *BoardService) Create(board *Board) (*Board, *http.Response, error) {
|
||||
}
|
||||
return responseBoard, resp, nil
|
||||
}
|
||||
|
||||
// Deletes the board.
|
||||
//
|
||||
// https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/board-deleteBoard
|
||||
func (s *BoardService) Delete(boardID int) (*Board, *http.Response, error) {
|
||||
apiEndpoint := fmt.Sprintf("rest/agile/1.0/board/%v", boardID)
|
||||
req, err := s.client.NewRequest("DELETE", apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
resp, err := s.client.Do(req, nil)
|
||||
return nil, resp, err
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func TestBoardGet(t *testing.T) {
|
||||
fmt.Fprint(w, `{"id":4,"self":"https://test.jira.org/rest/agile/1.0/board/1","name":"Test Weekly","type":"scrum"}`)
|
||||
})
|
||||
|
||||
board, _, err := testClient.Board.Get("1")
|
||||
board, _, err := testClient.Board.Get(1)
|
||||
if board == nil {
|
||||
t.Error("Expected board list. Board list is nil")
|
||||
}
|
||||
@ -95,7 +95,7 @@ func TestBoardGet_NoBoard(t *testing.T) {
|
||||
fmt.Fprint(w, nil)
|
||||
})
|
||||
|
||||
board, resp, err := testClient.Board.Get("99999999")
|
||||
board, resp, err := testClient.Board.Get(99999999)
|
||||
if board != nil {
|
||||
t.Errorf("Expected nil. Got %s", err)
|
||||
}
|
||||
@ -132,3 +132,23 @@ func TestBoardCreate(t *testing.T) {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBoardDelete(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/agile/1.0/board/1", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "DELETE")
|
||||
testRequestURL(t, r, "/rest/agile/1.0/board/1")
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
fmt.Fprint(w, `{}`)
|
||||
})
|
||||
|
||||
_, resp, err := testClient.Board.Delete(1)
|
||||
if resp.StatusCode != 204 {
|
||||
t.Error("Expected board not deleted.")
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user