mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-03-27 21:38:54 +02:00
Feature: Implement delete issue link api (#341)
This commit is contained in:
parent
524ede3750
commit
5601d2bfe2
23
issue.go
23
issue.go
@ -718,6 +718,29 @@ func (s *IssueService) DeleteAttachment(attachmentID string) (*Response, error)
|
||||
return s.DeleteAttachmentWithContext(context.Background(), attachmentID)
|
||||
}
|
||||
|
||||
// DeleteLinkWithContext deletes a link of a given linkID
|
||||
func (s *IssueService) DeleteLinkWithContext(ctx context.Context, linkID string) (*Response, error) {
|
||||
apiEndpoint := fmt.Sprintf("rest/api/2/issueLink/%s", linkID)
|
||||
|
||||
req, err := s.client.NewRequestWithContext(ctx, "DELETE", apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := s.client.Do(req, nil)
|
||||
if err != nil {
|
||||
jerr := NewJiraError(resp, err)
|
||||
return resp, jerr
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// DeleteLink wraps DeleteLinkWithContext using the background context.
|
||||
func (s *IssueService) DeleteLink(linkID string) (*Response, error) {
|
||||
return s.DeleteLinkWithContext(context.Background(), linkID)
|
||||
}
|
||||
|
||||
// GetWorklogsWithContext gets all the worklogs for an issue.
|
||||
// This method is especially important if you need to read all the worklogs, not just the first page.
|
||||
//
|
||||
|
@ -589,6 +589,33 @@ func TestIssueService_DeleteAttachment(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueService_DeleteLink(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issueLink/10054", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "DELETE")
|
||||
testRequestURL(t, r, "/rest/api/2/issueLink/10054")
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
fmt.Fprint(w, `{}`)
|
||||
})
|
||||
|
||||
resp, err := testClient.Issue.DeleteLink("10054")
|
||||
if resp.StatusCode != 204 {
|
||||
t.Error("Expected link not deleted.")
|
||||
if resp.StatusCode == 403 {
|
||||
t.Error("User not permitted to delete link")
|
||||
}
|
||||
if resp.StatusCode == 404 {
|
||||
t.Error("Link not found")
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueService_Search(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
Loading…
x
Reference in New Issue
Block a user