aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-24 20:19:16 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-24 20:19:16 +0200
commita72ea453a919b8f456cc46fbb7a1156d9f649442 (patch)
treefd3b0abae75df2d29184a3b98c681badce8ee4c8 /tests
parentc4a207622a894ba9839f1a3c47c9d78beff9b861 (diff)
downloadgit-bug-a72ea453a919b8f456cc46fbb7a1156d9f649442.tar.gz
bug: add the ability to store arbitrary metadata on an operation
Diffstat (limited to 'tests')
-rw-r--r--tests/operation_iterator_test.go3
-rw-r--r--tests/operation_pack_test.go20
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/operation_iterator_test.go b/tests/operation_iterator_test.go
index 790c8a62..52778e71 100644
--- a/tests/operation_iterator_test.go
+++ b/tests/operation_iterator_test.go
@@ -25,6 +25,7 @@ func TestOpIterator(t *testing.T) {
bug1 := bug.NewBug()
+ // first pack
bug1.Append(createOp)
bug1.Append(setTitleOp)
bug1.Append(addCommentOp)
@@ -32,11 +33,13 @@ func TestOpIterator(t *testing.T) {
bug1.Append(labelChangeOp)
bug1.Commit(mockRepo)
+ // second pack
bug1.Append(setTitleOp)
bug1.Append(setTitleOp)
bug1.Append(setTitleOp)
bug1.Commit(mockRepo)
+ // staging
bug1.Append(setTitleOp)
bug1.Append(setTitleOp)
bug1.Append(setTitleOp)
diff --git a/tests/operation_pack_test.go b/tests/operation_pack_test.go
index 62f406a4..d7393c29 100644
--- a/tests/operation_pack_test.go
+++ b/tests/operation_pack_test.go
@@ -6,6 +6,8 @@ import (
"testing"
"github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/operations"
+ "github.com/MichaelMure/git-bug/util/git"
)
func TestOperationPackSerialize(t *testing.T) {
@@ -17,6 +19,24 @@ func TestOperationPackSerialize(t *testing.T) {
opp.Append(setStatusOp)
opp.Append(labelChangeOp)
+ opMeta := operations.NewCreateOp(rene, "title", "message", nil)
+ opMeta.SetMetadata("key", "value")
+ opp.Append(opMeta)
+
+ if len(opMeta.Metadata) != 1 {
+ t.Fatal()
+ }
+
+ opFile := operations.NewCreateOp(rene, "title", "message", []git.Hash{
+ "abcdef",
+ "ghijkl",
+ })
+ opp.Append(opFile)
+
+ if len(opFile.Files) != 2 {
+ t.Fatal()
+ }
+
data, err := json.Marshal(opp)
if err != nil {
t.Fatal(err)