aboutsummaryrefslogtreecommitdiffstats
path: root/bug/bug_test.go
diff options
context:
space:
mode:
authorMichael Muré <michael.mure@consensys.net>2019-02-06 22:06:42 +0100
committerMichael Muré <batolettre@gmail.com>2019-03-01 22:40:23 +0100
commit21048e785d976a04e26798e4a385ee675c95b88f (patch)
treeb525d1f5a45e8c828b140b26f6dcc3f7eb5af123 /bug/bug_test.go
parent328a4e5abf3ec8ea41f89575fcfb83cf9f086c80 (diff)
downloadgit-bug-21048e785d976a04e26798e4a385ee675c95b88f.tar.gz
identity: wip
Diffstat (limited to 'bug/bug_test.go')
-rw-r--r--bug/bug_test.go36
1 files changed, 22 insertions, 14 deletions
diff --git a/bug/bug_test.go b/bug/bug_test.go
index 41a5b03d..001bfc56 100644
--- a/bug/bug_test.go
+++ b/bug/bug_test.go
@@ -55,7 +55,7 @@ func TestBugValidity(t *testing.T) {
}
}
-func TestBugSerialisation(t *testing.T) {
+func TestBugCommitLoad(t *testing.T) {
bug1 := NewBug()
bug1.Append(createOp)
@@ -69,22 +69,30 @@ func TestBugSerialisation(t *testing.T) {
assert.Nil(t, err)
bug2, err := ReadLocalBug(repo, bug1.Id())
- if err != nil {
- t.Error(err)
- }
+ assert.NoError(t, err)
+ equivalentBug(t, bug1, bug2)
- // ignore some fields
- bug2.packs[0].commitHash = bug1.packs[0].commitHash
- for i := range bug1.packs[0].Operations {
- bug2.packs[0].Operations[i].base().hash = bug1.packs[0].Operations[i].base().hash
- }
+ // add more op
+
+ bug1.Append(setTitleOp)
+ bug1.Append(addCommentOp)
+
+ err = bug1.Commit(repo)
+ assert.Nil(t, err)
+
+ bug3, err := ReadLocalBug(repo, bug1.Id())
+ assert.NoError(t, err)
+ equivalentBug(t, bug1, bug3)
+}
+
+func equivalentBug(t *testing.T, expected, actual *Bug) {
+ assert.Equal(t, len(expected.packs), len(actual.packs))
- // check hashes
- for i := range bug1.packs[0].Operations {
- if !bug2.packs[0].Operations[i].base().hash.IsValid() {
- t.Fatal("invalid hash")
+ for i := range expected.packs {
+ for j := range expected.packs[i].Operations {
+ actual.packs[i].Operations[j].base().hash = expected.packs[i].Operations[j].base().hash
}
}
- assert.Equal(t, bug1, bug2)
+ assert.Equal(t, expected, actual)
}