diff options
Diffstat (limited to 'bug/op_edit_comment_test.go')
-rw-r--r-- | bug/op_edit_comment_test.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/bug/op_edit_comment_test.go b/bug/op_edit_comment_test.go index abd550cb..583ba656 100644 --- a/bug/op_edit_comment_test.go +++ b/bug/op_edit_comment_test.go @@ -9,12 +9,17 @@ import ( "github.com/stretchr/testify/require" "github.com/MichaelMure/git-bug/identity" + "github.com/MichaelMure/git-bug/repository" ) func TestEdit(t *testing.T) { snapshot := Snapshot{} - rene := identity.NewBare("René Descartes", "rene@descartes.fr") + repo := repository.NewMockRepoForTest() + rene := identity.NewIdentity("René Descartes", "rene@descartes.fr") + err := rene.Commit(repo) + require.NoError(t, err) + unix := time.Now().Unix() create := NewCreateOp(rene, unix, "title", "create", nil) @@ -74,7 +79,11 @@ func TestEdit(t *testing.T) { } func TestEditCommentSerialize(t *testing.T) { - var rene = identity.NewBare("René Descartes", "rene@descartes.fr") + repo := repository.NewMockRepoForTest() + rene := identity.NewIdentity("René Descartes", "rene@descartes.fr") + err := rene.Commit(repo) + require.NoError(t, err) + unix := time.Now().Unix() before := NewEditCommentOp(rene, unix, "target", "message", nil) @@ -85,9 +94,12 @@ func TestEditCommentSerialize(t *testing.T) { err = json.Unmarshal(data, &after) assert.NoError(t, err) - // enforce creating the IDs + // enforce creating the ID before.Id() - rene.Id() + + // Replace the identity stub with the real thing + assert.Equal(t, rene.Id(), after.base().Author.Id()) + after.Author = rene assert.Equal(t, before, &after) } |