aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bug_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bug_test.go')
-rw-r--r--tests/bug_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/bug_test.go b/tests/bug_test.go
new file mode 100644
index 00000000..dfb3ac09
--- /dev/null
+++ b/tests/bug_test.go
@@ -0,0 +1,46 @@
+package tests
+
+import (
+ "github.com/MichaelMure/git-bug/bug"
+ "testing"
+)
+
+func TestBugId(t *testing.T) {
+ bug1, err := bug.NewBug()
+ if err != nil {
+ t.Error(err)
+ }
+
+ if len(bug1.HumanId()) == 0 {
+ t.Fatal("Bug doesn't have a human readable identifier")
+ }
+}
+
+func TestBugValidity(t *testing.T) {
+ 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")
+ }
+}