aboutsummaryrefslogtreecommitdiffstats
path: root/test/operation_iterator_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-13 16:48:55 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-13 16:48:55 +0200
commitdeff9e0a41eca43f832314219241c9a63cf8007e (patch)
tree215e07e7a77972cee50268603eeb3777de583e8b /test/operation_iterator_test.go
parent078545538e6e6bf7a050fe6602a42a61fb5203e9 (diff)
downloadgit-bug-deff9e0a41eca43f832314219241c9a63cf8007e.tar.gz
add basic tests for Bug and OperationIterator
Diffstat (limited to 'test/operation_iterator_test.go')
-rw-r--r--test/operation_iterator_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/operation_iterator_test.go b/test/operation_iterator_test.go
new file mode 100644
index 00000000..d8e78a1f
--- /dev/null
+++ b/test/operation_iterator_test.go
@@ -0,0 +1,48 @@
+package test
+
+import (
+ "github.com/MichaelMure/git-bug/bug"
+ "github.com/MichaelMure/git-bug/bug/operations"
+ "testing"
+)
+
+func TestOpIterator(t *testing.T) {
+ var rene = bug.Person{
+ Name: "René Descartes",
+ Email: "rene@descartes.fr",
+ }
+
+ var createOp = operations.NewCreateOp(rene, "title", "message")
+ var setTitleOp = operations.NewSetTitleOp("title2")
+
+ bug1, err := bug.NewBug()
+
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ bug1.Append(createOp)
+ bug1.Append(setTitleOp)
+ bug1.Commit()
+
+ bug1.Append(setTitleOp)
+ bug1.Append(setTitleOp)
+ bug1.Append(setTitleOp)
+ bug1.Commit()
+
+ bug1.Append(setTitleOp)
+ bug1.Append(setTitleOp)
+ bug1.Append(setTitleOp)
+
+ it := bug.NewOperationIterator(bug1)
+
+ counter := 0
+ for it.Next() {
+ _ = it.Value()
+ counter++
+ }
+
+ if counter != 8 {
+ t.Fatalf("Wrong count of value iterated (%d instead of 8)", counter)
+ }
+}