aboutsummaryrefslogtreecommitdiffstats
path: root/bug/op_set_metadata_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'bug/op_set_metadata_test.go')
-rw-r--r--bug/op_set_metadata_test.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/bug/op_set_metadata_test.go b/bug/op_set_metadata_test.go
index 389e91ac..d7711249 100644
--- a/bug/op_set_metadata_test.go
+++ b/bug/op_set_metadata_test.go
@@ -6,6 +6,8 @@ import (
"time"
"github.com/MichaelMure/git-bug/identity"
+ "github.com/MichaelMure/git-bug/repository"
+
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -13,7 +15,11 @@ import (
func TestSetMetadata(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)
@@ -93,7 +99,11 @@ func TestSetMetadata(t *testing.T) {
}
func TestSetMetadataSerialize(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 := NewSetMetadataOp(rene, unix, "message", map[string]string{
"key1": "value1",
@@ -107,9 +117,12 @@ func TestSetMetadataSerialize(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)
}