aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bug_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bug_test.go')
-rw-r--r--tests/bug_test.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/bug_test.go b/tests/bug_test.go
index ab7803f9..2fb79be5 100644
--- a/tests/bug_test.go
+++ b/tests/bug_test.go
@@ -2,6 +2,8 @@ package tests
import (
"github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/repository"
+ "reflect"
"testing"
)
@@ -11,7 +13,7 @@ func TestBugId(t *testing.T) {
t.Error(err)
}
- if len(bug1.HumanId()) == 0 {
+ if len(bug1.Id()) == 0 {
t.Fatal("Bug doesn't have a human readable identifier")
}
}
@@ -44,3 +46,28 @@ func TestBugValidity(t *testing.T) {
t.Fatal("Bug with multiple CREATE should be invalid")
}
}
+
+func TestBugSerialisation(t *testing.T) {
+ bug1, err := bug.NewBug()
+ if err != nil {
+ t.Error(err)
+ }
+
+ bug1.Append(createOp)
+ bug1.Append(setTitleOp)
+ bug1.Append(setTitleOp)
+ bug1.Append(addCommentOp)
+
+ repo := repository.NewMockRepoForTest()
+
+ bug1.Commit(repo)
+
+ bug2, err := bug.ReadBug(repo, bug1.Id())
+ if err != nil {
+ t.Error(err)
+ }
+
+ if !reflect.DeepEqual(bug1, bug2) {
+ t.Fatalf("%s different than %s", bug1, bug2)
+ }
+}