diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-13 16:48:55 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-13 16:48:55 +0200 |
commit | deff9e0a41eca43f832314219241c9a63cf8007e (patch) | |
tree | 215e07e7a77972cee50268603eeb3777de583e8b /test/bug_test.go | |
parent | 078545538e6e6bf7a050fe6602a42a61fb5203e9 (diff) | |
download | git-bug-deff9e0a41eca43f832314219241c9a63cf8007e.tar.gz |
add basic tests for Bug and OperationIterator
Diffstat (limited to 'test/bug_test.go')
-rw-r--r-- | test/bug_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/bug_test.go b/test/bug_test.go new file mode 100644 index 00000000..d7c3ddc5 --- /dev/null +++ b/test/bug_test.go @@ -0,0 +1,44 @@ +package test + +import ( + "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/bug/operations" + "testing" +) + +func TestBug(t *testing.T) { + var rene = bug.Person{ + Name: "René Descartes", + Email: "rene@descartes.fr", + } + + var createOp = operations.NewCreateOp(rene, "title", "message") + + bug1, err := bug.NewBug() + + if err != nil { + t.Error(err) + } + + if bug1.IsValid() { + t.Fatal("Empty bug should be invalid") + } + + bug1.Append(createOp) + + if !bug1.IsValid() { + t.Fatal("Bug with just a CREATE should be valid") + } + + bug1.Append(createOp) + + if bug1.IsValid() { + t.Fatal("Bug with multiple CREATE should be invalid") + } + + bug1.Commit() + + if bug1.IsValid() { + t.Fatal("Bug with multiple CREATE should be invalid") + } +} |