aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operation_iterator_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-30 11:10:03 +0200
committerGitHub <noreply@github.com>2018-09-30 11:10:03 +0200
commitd71bb7dd7632780cf5aad5fda84027fa03a9d0f0 (patch)
treedba6c3c0bab18f41e21cd36a9fe05d1d27a574d4 /bug/operation_iterator_test.go
parent8fdd6bf99c111c3756056e87ffd9209875ac5c1f (diff)
parentbad9cda969b49bf1bce6799056476ac4684892df (diff)
downloadgit-bug-d71bb7dd7632780cf5aad5fda84027fa03a9d0f0.tar.gz
Merge pull request #54 from MichaelMure/editablecomment
Core support for editable comments
Diffstat (limited to 'bug/operation_iterator_test.go')
-rw-r--r--bug/operation_iterator_test.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/bug/operation_iterator_test.go b/bug/operation_iterator_test.go
new file mode 100644
index 00000000..506cc94f
--- /dev/null
+++ b/bug/operation_iterator_test.go
@@ -0,0 +1,59 @@
+package bug
+
+import (
+ "github.com/MichaelMure/git-bug/repository"
+ "testing"
+ "time"
+)
+
+var (
+ rene = Person{
+ Name: "René Descartes",
+ Email: "rene@descartes.fr",
+ }
+
+ unix = time.Now().Unix()
+
+ createOp = NewCreateOp(rene, unix, "title", "message", nil)
+ setTitleOp = NewSetTitleOp(rene, unix, "title2", "title1")
+ addCommentOp = NewAddCommentOp(rene, unix, "message2", nil)
+ setStatusOp = NewSetStatusOp(rene, unix, ClosedStatus)
+ labelChangeOp = NewLabelChangeOperation(rene, unix, []Label{"added"}, []Label{"removed"})
+)
+
+func TestOpIterator(t *testing.T) {
+ mockRepo := repository.NewMockRepoForTest()
+
+ bug1 := NewBug()
+
+ // first pack
+ bug1.Append(createOp)
+ bug1.Append(setTitleOp)
+ bug1.Append(addCommentOp)
+ bug1.Append(setStatusOp)
+ 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)
+
+ it := NewOperationIterator(bug1)
+
+ counter := 0
+ for it.Next() {
+ _ = it.Value()
+ counter++
+ }
+
+ if counter != 11 {
+ t.Fatalf("Wrong count of value iterated (%d instead of 8)", counter)
+ }
+}