1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-12-03 22:39:24 +02:00

Added AddComment to IssueService

This commit is contained in:
Andy Grunwald
2016-03-27 14:03:40 +02:00
parent bc2f1e8320
commit f40a31fe85
2 changed files with 72 additions and 41 deletions

View File

@@ -25,7 +25,7 @@ func TestIssueGet_Success(t *testing.T) {
}
}
func TestIssueCreate_Success(t *testing.T) {
func TestIssueCreate(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/rest/api/2/issue/", func(w http.ResponseWriter, r *http.Request) {
@@ -49,3 +49,30 @@ func TestIssueCreate_Success(t *testing.T) {
t.Error("Error given: %s", err)
}
}
func TestIssueAddComment(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/rest/api/2/issue/10000/comment", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testRequestURL(t, r, "/rest/api/2/issue/10000/comment")
w.WriteHeader(http.StatusCreated)
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/issue/10010/comment/10000","id":"10000","author":{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","name":"fred","displayName":"Fred F. User","active":false},"body":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.","updateAuthor":{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","name":"fred","displayName":"Fred F. User","active":false},"created":"2016-03-16T04:22:37.356+0000","updated":"2016-03-16T04:22:37.356+0000","visibility":{"type":"role","value":"Administrators"}}`)
})
c := &Comment{
Body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
Visibility: CommentVisibility{
Type: "role",
Value: "Administrators",
},
}
comment, _, err := testClient.Issue.AddComment("10000", c)
if comment == nil {
t.Errorf("Expected Comment. Comment is nil")
}
if err != nil {
t.Error("Error given: %s", err)
}
}