diff options
author | Michael Muré <batolettre@gmail.com> | 2021-02-14 11:36:32 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2021-02-14 12:19:50 +0100 |
commit | 3f6ef50883492f77995a7e27872d0b5ae17b9d6a (patch) | |
tree | 97677642f1b01c73c8c5a708ea0ec67ced8c402f /bug/operation_iterator_test.go | |
parent | 99b9dd84cb4b0cfd3eb1fd50b07c8b826eb52d19 (diff) | |
download | git-bug-3f6ef50883492f77995a7e27872d0b5ae17b9d6a.tar.gz |
bug: migrate to the DAG entity structure!
Diffstat (limited to 'bug/operation_iterator_test.go')
-rw-r--r-- | bug/operation_iterator_test.go | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/bug/operation_iterator_test.go b/bug/operation_iterator_test.go deleted file mode 100644 index 81d87a5f..00000000 --- a/bug/operation_iterator_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package bug - -import ( - "fmt" - "testing" - "time" - - "github.com/stretchr/testify/require" - - "github.com/MichaelMure/git-bug/identity" - "github.com/MichaelMure/git-bug/repository" -) - -func ExampleOperationIterator() { - b := NewBug() - - // add operations - - it := NewOperationIterator(b) - - for it.Next() { - // do something with each operations - _ = it.Value() - } -} - -func TestOpIterator(t *testing.T) { - repo := repository.NewMockRepo() - - rene, err := identity.NewIdentity(repo, "René Descartes", "rene@descartes.fr") - require.NoError(t, err) - err = rene.Commit(repo) - require.NoError(t, err) - - unix := time.Now().Unix() - - createOp := NewCreateOp(rene, unix, "title", "message", nil) - addCommentOp := NewAddCommentOp(rene, unix, "message2", nil) - setStatusOp := NewSetStatusOp(rene, unix, ClosedStatus) - labelChangeOp := NewLabelChangeOperation(rene, unix, []Label{"added"}, []Label{"removed"}) - - var i int - genTitleOp := func() Operation { - i++ - return NewSetTitleOp(rene, unix, fmt.Sprintf("title%d", i), "") - } - - bug1 := NewBug() - - // first pack - bug1.Append(createOp) - bug1.Append(addCommentOp) - bug1.Append(setStatusOp) - bug1.Append(labelChangeOp) - err = bug1.Commit(repo) - require.NoError(t, err) - - // second pack - bug1.Append(genTitleOp()) - bug1.Append(genTitleOp()) - bug1.Append(genTitleOp()) - err = bug1.Commit(repo) - require.NoError(t, err) - - // staging - bug1.Append(genTitleOp()) - bug1.Append(genTitleOp()) - bug1.Append(genTitleOp()) - - it := NewOperationIterator(bug1) - - counter := 0 - for it.Next() { - _ = it.Value() - counter++ - } - - require.Equal(t, 10, counter) -} |