diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-30 11:10:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-30 11:10:03 +0200 |
commit | d71bb7dd7632780cf5aad5fda84027fa03a9d0f0 (patch) | |
tree | dba6c3c0bab18f41e21cd36a9fe05d1d27a574d4 /bug/op_edit_comment_test.go | |
parent | 8fdd6bf99c111c3756056e87ffd9209875ac5c1f (diff) | |
parent | bad9cda969b49bf1bce6799056476ac4684892df (diff) | |
download | git-bug-d71bb7dd7632780cf5aad5fda84027fa03a9d0f0.tar.gz |
Merge pull request #54 from MichaelMure/editablecomment
Core support for editable comments
Diffstat (limited to 'bug/op_edit_comment_test.go')
-rw-r--r-- | bug/op_edit_comment_test.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/bug/op_edit_comment_test.go b/bug/op_edit_comment_test.go new file mode 100644 index 00000000..9c32051d --- /dev/null +++ b/bug/op_edit_comment_test.go @@ -0,0 +1,53 @@ +package bug + +import ( + "testing" + "time" + + "gotest.tools/assert" +) + +func TestEdit(t *testing.T) { + snapshot := Snapshot{} + + var rene = Person{ + Name: "René Descartes", + Email: "rene@descartes.fr", + } + + unix := time.Now().Unix() + + create := NewCreateOp(rene, unix, "title", "create", nil) + create.Apply(&snapshot) + + hash1, err := create.Hash() + if err != nil { + t.Fatal(err) + } + + comment := NewAddCommentOp(rene, unix, "comment", nil) + comment.Apply(&snapshot) + + hash2, err := comment.Hash() + if err != nil { + t.Fatal(err) + } + + edit := NewEditCommentOp(rene, unix, hash1, "create edited", nil) + edit.Apply(&snapshot) + + assert.Equal(t, len(snapshot.Timeline), 2) + assert.Equal(t, len(snapshot.Timeline[0].(*CreateTimelineItem).History), 2) + assert.Equal(t, len(snapshot.Timeline[1].(*CommentTimelineItem).History), 1) + assert.Equal(t, snapshot.Comments[0].Message, "create edited") + assert.Equal(t, snapshot.Comments[1].Message, "comment") + + edit2 := NewEditCommentOp(rene, unix, hash2, "comment edited", nil) + edit2.Apply(&snapshot) + + assert.Equal(t, len(snapshot.Timeline), 2) + assert.Equal(t, len(snapshot.Timeline[0].(*CreateTimelineItem).History), 2) + assert.Equal(t, len(snapshot.Timeline[1].(*CommentTimelineItem).History), 2) + assert.Equal(t, snapshot.Comments[0].Message, "create edited") + assert.Equal(t, snapshot.Comments[1].Message, "comment edited") +} |