diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bug_test.go | 26 | ||||
-rw-r--r-- | tests/operation_iterator_test.go | 2 |
2 files changed, 17 insertions, 11 deletions
diff --git a/tests/bug_test.go b/tests/bug_test.go index fdda31b1..02336974 100644 --- a/tests/bug_test.go +++ b/tests/bug_test.go @@ -2,10 +2,14 @@ package tests import ( "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/repository" + "testing" ) func TestBugId(t *testing.T) { + mockRepo := repository.NewMockRepoForTest() + bug1 := bug.NewBug() bug1.Append(createOp) @@ -20,33 +24,35 @@ func TestBugId(t *testing.T) { } func TestBugValidity(t *testing.T) { + mockRepo := repository.NewMockRepoForTest() + bug1 := bug.NewBug() - if bug1.IsValid() { + if bug1.Validate() == nil { t.Fatal("Empty bug should be invalid") } bug1.Append(createOp) - if !bug1.IsValid() { + if bug1.Validate() != nil { t.Fatal("Bug with just a CreateOp should be valid") } - bug1.Append(createOp) - - if bug1.IsValid() { - t.Fatal("Bug with multiple CreateOp should be invalid") - } - err := bug1.Commit(mockRepo) - if err != nil { t.Fatal(err) } - if bug1.IsValid() { + bug1.Append(createOp) + + if bug1.Validate() == nil { t.Fatal("Bug with multiple CreateOp should be invalid") } + + err = bug1.Commit(mockRepo) + if err == nil { + t.Fatal("Invalid bug should not commit") + } } //func TestBugSerialisation(t *testing.T) { diff --git a/tests/operation_iterator_test.go b/tests/operation_iterator_test.go index f1840091..790c8a62 100644 --- a/tests/operation_iterator_test.go +++ b/tests/operation_iterator_test.go @@ -18,10 +18,10 @@ var ( addCommentOp = operations.NewAddCommentOp(rene, "message2", nil) setStatusOp = operations.NewSetStatusOp(rene, bug.ClosedStatus) labelChangeOp = operations.NewLabelChangeOperation(rene, []bug.Label{"added"}, []bug.Label{"removed"}) - mockRepo = repository.NewMockRepoForTest() ) func TestOpIterator(t *testing.T) { + mockRepo := repository.NewMockRepoForTest() bug1 := bug.NewBug() |