aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operation_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-10-01 21:44:42 +0200
committerMichael Muré <batolettre@gmail.com>2018-10-01 21:44:42 +0200
commit97d94948536b119b4825d30c546248f91c41988d (patch)
tree6b9d48463172b99907d6fd2d30cce4c86cb1aba9 /bug/operation_test.go
parentbda9b01b5a1e037b64e18d34bcf2c06904663942 (diff)
downloadgit-bug-97d94948536b119b4825d30c546248f91c41988d.tar.gz
bug: add a test for operations hash
Diffstat (limited to 'bug/operation_test.go')
-rw-r--r--bug/operation_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/bug/operation_test.go b/bug/operation_test.go
index 13373761..9296e247 100644
--- a/bug/operation_test.go
+++ b/bug/operation_test.go
@@ -3,6 +3,7 @@ package bug
import (
"testing"
+ "github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/git"
"github.com/stretchr/testify/require"
)
@@ -71,3 +72,38 @@ func TestMetadata(t *testing.T) {
require.True(t, ok)
require.Equal(t, val, "value")
}
+
+func TestHash(t *testing.T) {
+ repos := []repository.ClockedRepo{
+ repository.NewMockRepoForTest(),
+ createRepo(false),
+ }
+
+ for _, repo := range repos {
+ b, op, err := Create(rene, unix, "title", "message")
+ require.Nil(t, err)
+
+ h1, err := op.Hash()
+ require.Nil(t, err)
+
+ err = b.Commit(repo)
+ require.Nil(t, err)
+
+ op2 := b.FirstOp()
+
+ h2, err := op2.Hash()
+ require.Nil(t, err)
+
+ require.Equal(t, h1, h2)
+
+ b2, err := ReadLocalBug(repo, b.id)
+ require.Nil(t, err)
+
+ op3 := b2.FirstOp()
+
+ h3, err := op3.Hash()
+ require.Nil(t, err)
+
+ require.Equal(t, h1, h3)
+ }
+}