mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-06-27 00:21:07 +02:00
Merge pull request #65 from ggrpmnn/delete
Feature addition: Issue delete
This commit is contained in:
@ -76,7 +76,7 @@ func TestAuthenticationService_AcquireSessionCookie_Success(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if testClient.Authentication.authType != authTypeSession {
|
if testClient.Authentication.authType != authTypeSession {
|
||||||
t.Error("Expected authType %d. Got %d", authTypeSession, testClient.Authentication.authType)
|
t.Errorf("Expected authType %d. Got %d", authTypeSession, testClient.Authentication.authType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,15 +87,15 @@ func TestAuthenticationService_SetBasicAuth(t *testing.T) {
|
|||||||
testClient.Authentication.SetBasicAuth("test-user", "test-password")
|
testClient.Authentication.SetBasicAuth("test-user", "test-password")
|
||||||
|
|
||||||
if testClient.Authentication.username != "test-user" {
|
if testClient.Authentication.username != "test-user" {
|
||||||
t.Error("Expected username test-user. Got %s", testClient.Authentication.username)
|
t.Errorf("Expected username test-user. Got %s", testClient.Authentication.username)
|
||||||
}
|
}
|
||||||
|
|
||||||
if testClient.Authentication.password != "test-password" {
|
if testClient.Authentication.password != "test-password" {
|
||||||
t.Error("Expected password test-password. Got %s", testClient.Authentication.password)
|
t.Errorf("Expected password test-password. Got %s", testClient.Authentication.password)
|
||||||
}
|
}
|
||||||
|
|
||||||
if testClient.Authentication.authType != authTypeBasic {
|
if testClient.Authentication.authType != authTypeBasic {
|
||||||
t.Error("Expected authType %d. Got %d", authTypeBasic, testClient.Authentication.authType)
|
t.Errorf("Expected authType %d. Got %d", authTypeBasic, testClient.Authentication.authType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
issue.go
20
issue.go
@ -435,7 +435,7 @@ type SearchOptions struct {
|
|||||||
// MaxResults: The maximum number of projects to return per page. Default: 50.
|
// MaxResults: The maximum number of projects to return per page. Default: 50.
|
||||||
MaxResults int `url:"maxResults,omitempty"`
|
MaxResults int `url:"maxResults,omitempty"`
|
||||||
// Expand: Expand specific sections in the returned issues
|
// Expand: Expand specific sections in the returned issues
|
||||||
Expand string `url:expand,omitempty"`
|
Expand string `url:"expand,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// searchResult is only a small wrapper around the Search (with JQL) method
|
// searchResult is only a small wrapper around the Search (with JQL) method
|
||||||
@ -783,3 +783,21 @@ func InitIssueWithMetaAndFields(metaProject *MetaProject, metaIssuetype *MetaIss
|
|||||||
|
|
||||||
return issue, nil
|
return issue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete will delete a specified issue.
|
||||||
|
func (s *IssueService) Delete(issueID string) (*Response, error) {
|
||||||
|
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%s", issueID)
|
||||||
|
|
||||||
|
// to enable deletion of subtasks; without this, the request will fail if the issue has subtasks
|
||||||
|
deletePayload := make(map[string]interface{})
|
||||||
|
deletePayload["deleteSubtasks"] = "true"
|
||||||
|
content, _ := json.Marshal(deletePayload)
|
||||||
|
|
||||||
|
req, err := s.client.NewRequest("DELETE", apiEndpoint, content)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := s.client.Do(req, nil)
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
@ -957,3 +957,23 @@ func TestInitIssueWithmetaAndFields_FailureWithUnknownValueType(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssueService_Delete(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, "DELETE")
|
||||||
|
testRequestURL(t, r, "/rest/api/2/issue/10002")
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
fmt.Fprint(w, `{}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
resp, err := testClient.Issue.Delete("10002")
|
||||||
|
if resp.StatusCode != 204 {
|
||||||
|
t.Error("Expected issue not deleted.")
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error given: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -37,7 +37,7 @@ type MetaIssueType struct {
|
|||||||
IconUrl string `json:"iconurl,omitempty"`
|
IconUrl string `json:"iconurl,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Subtasks bool `json:"subtask,omitempty"`
|
Subtasks bool `json:"subtask,omitempty"`
|
||||||
Expand string `json:"expand,omitempty"`
|
Expand string `json:",omitempty"`
|
||||||
Fields tcontainer.MarshalMap `json:"fields,omitempty"`
|
Fields tcontainer.MarshalMap `json:"fields,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user