bug_test.go

 1package test
 2
 3import (
 4	"github.com/MichaelMure/git-bug/bug"
 5	"github.com/MichaelMure/git-bug/bug/operations"
 6	"testing"
 7)
 8
 9func TestBug(t *testing.T) {
10	var rene = bug.Person{
11		Name:  "René Descartes",
12		Email: "rene@descartes.fr",
13	}
14
15	var createOp = operations.NewCreateOp(rene, "title", "message")
16
17	bug1, err := bug.NewBug()
18
19	if err != nil {
20		t.Error(err)
21	}
22
23	if bug1.IsValid() {
24		t.Fatal("Empty bug should be invalid")
25	}
26
27	bug1.Append(createOp)
28
29	if !bug1.IsValid() {
30		t.Fatal("Bug with just a CREATE should be valid")
31	}
32
33	bug1.Append(createOp)
34
35	if bug1.IsValid() {
36		t.Fatal("Bug with multiple CREATE should be invalid")
37	}
38
39	bug1.Commit()
40
41	if bug1.IsValid() {
42		t.Fatal("Bug with multiple CREATE should be invalid")
43	}
44}