Skip to content

Commit

Permalink
Merge pull request #13 from wolftatsu/comment-api-testcase-1
Browse files Browse the repository at this point in the history
Improve comment-api Testcase
  • Loading branch information
cy-kaneko authored Sep 27, 2017
2 parents 75f932a + 0c54527 commit 8bd0b19
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package kintone
import "testing"

func TestDecodeRecordComments(t *testing.T) {
j := []byte(`
{"comments":[{"id":"2","text":"ほげほげ","createdAt":"2016-11-07T19:53:32Z","creator":{"code":"xxx.tat","name":"さんぷる"},"mentions":[]},{"id":"1","text":"ふがふが","createdAt":"2016-11-07T19:53:27Z","creator":{"code":"xxx.tat","name":"さんぷる"},"mentions":[]}],"older":false,"newer":false}
j := []byte(`
{"comments":[{"id":"2","text":"ほげほげ","createdAt":"2016-11-07T19:53:32Z","creator":{"code":"xxx.tat","name":"さんぷる"},"mentions":[{"code":"wolf","type":"USER"}]},{"id":"1","text":"ふがふが","createdAt":"2016-11-07T19:53:27Z","creator":{"code":"xxx.tat","name":"さんぷる"},"mentions":[]}],"older":false,"newer":false}
`)

rec, err := DecodeRecordComments(j)
Expand All @@ -20,4 +20,14 @@ func TestDecodeRecordComments(t *testing.T) {
if rec[0].Text != "ほげほげ" {
t.Errorf("comment text mismatch. actual %v", rec[0].Text)
}

if rec[0].CreatedAt != "2016-11-07T19:53:32Z" {
t.Errorf("comment createdat mismatch. actual %v", rec[0].CreatedAt)
}
if rec[0].Creator.Code != "xxx.tat" {
t.Errorf("comment creator mismatch. actual %v", rec[0].Creator.Code)
}
if rec[0].Mentions[0].Code != "wolf" {
t.Errorf("comment mention-code mismatch. actual %v", rec[0].Mentions[0].Code)
}
}

0 comments on commit 8bd0b19

Please sign in to comment.