1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package tests
import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/operations"
"github.com/MichaelMure/git-bug/repository"
"testing"
)
var (
rene = bug.Person{
Name: "René Descartes",
Email: "rene@descartes.fr",
}
createOp = operations.NewCreateOp(rene, "title", "message", nil)
setTitleOp = operations.NewSetTitleOp(rene, "title2", "title1")
addCommentOp = operations.NewAddCommentOp(rene, "message2", nil)
setStatusOp = operations.NewSetStatusOp(rene, bug.ClosedStatus)
labelChangeOp = operations.NewLabelChangeOperation(rene, []bug.Label{"added"}, []bug.Label{"removed"})
)
func TestOpIterator(t *testing.T) {
mockRepo := repository.NewMockRepoForTest()
bug1 := bug.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 := bug.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)
}
}
|