aboutsummaryrefslogtreecommitdiffstats
path: root/bug
diff options
context:
space:
mode:
Diffstat (limited to 'bug')
-rw-r--r--bug/bug.go5
-rw-r--r--bug/bug_test.go15
2 files changed, 18 insertions, 2 deletions
diff --git a/bug/bug.go b/bug/bug.go
index 24f0dcd5..04bd5996 100644
--- a/bug/bug.go
+++ b/bug/bug.go
@@ -242,6 +242,11 @@ func readBug(repo repository.ClockedRepo, ref string) (*Bug, error) {
return &bug, nil
}
+func RemoveLocalBug(repo repository.ClockedRepo, id entity.Id) error {
+ ref := bugsRefPattern + id.String()
+ return repo.RemoveRef(ref)
+}
+
type StreamedBug struct {
Bug *Bug
Err error
diff --git a/bug/bug_test.go b/bug/bug_test.go
index 480d312e..43e760af 100644
--- a/bug/bug_test.go
+++ b/bug/bug_test.go
@@ -4,9 +4,10 @@ import (
"testing"
"time"
+ "github.com/stretchr/testify/assert"
+
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/repository"
- "github.com/stretchr/testify/assert"
)
func TestBugId(t *testing.T) {
@@ -63,7 +64,7 @@ func TestBugValidity(t *testing.T) {
}
}
-func TestBugCommitLoad(t *testing.T) {
+func TestBugCommitLoadRemove(t *testing.T) {
bug1 := NewBug()
rene := identity.NewIdentity("René Descartes", "rene@descartes.fr")
@@ -99,6 +100,16 @@ func TestBugCommitLoad(t *testing.T) {
bug3, err := ReadLocalBug(repo, bug1.Id())
assert.NoError(t, err)
equivalentBug(t, bug1, bug3)
+
+ err = RemoveLocalBug(repo, bug1.Id())
+ assert.NoError(t, err)
+
+ streamedBugs := ReadAllLocalBugs(repo)
+ count := 0
+ for range streamedBugs {
+ count++
+ }
+ assert.Equal(t, 0, count)
}
func equivalentBug(t *testing.T, expected, actual *Bug) {