mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-11-29 22:28:34 +02:00
Add Issue Update method
JIRA only allows issues to be created with certain fields set. This means if a user needs to create an issue through the API with the description set, they need to create the issue first, and then call the API again to update it. Without this commit, the way to do this through the package is by calling IssueService.Create and then use the client's NewRequest method to create a raw HTTP request for the Update. This isn't bad, but it can be better.
This commit is contained in:
@@ -78,6 +78,31 @@ func TestIssueService_Create(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueService_Update(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "PUT")
|
||||
testRequestURL(t, r, "/rest/api/2/issue/10002")
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
})
|
||||
|
||||
i := &Issue{
|
||||
ID: "10002",
|
||||
Fields: &IssueFields{
|
||||
Description: "example bug report",
|
||||
},
|
||||
}
|
||||
issue, _, err := testClient.Issue.Update(i)
|
||||
if issue == nil {
|
||||
t.Error("Expected issue. Issue is nil")
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueService_AddComment(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
Reference in New Issue
Block a user