aboutsummaryrefslogtreecommitdiffstats
path: root/commands/env_testing.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/env_testing.go')
-rw-r--r--commands/env_testing.go22
1 files changed, 4 insertions, 18 deletions
diff --git a/commands/env_testing.go b/commands/env_testing.go
index 092ff233..4de66a9d 100644
--- a/commands/env_testing.go
+++ b/commands/env_testing.go
@@ -8,7 +8,6 @@ import (
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/repository"
- "github.com/MichaelMure/git-bug/util/interrupt"
)
type testEnv struct {
@@ -32,8 +31,11 @@ func newTestEnv(t *testing.T) *testEnv {
backend, err := cache.NewRepoCache(repo)
require.NoError(t, err)
+ t.Cleanup(func() {
+ backend.Close()
+ })
- testEnv := &testEnv{
+ return &testEnv{
env: &Env{
repo: repo,
backend: backend,
@@ -43,20 +45,4 @@ func newTestEnv(t *testing.T) *testEnv {
cwd: cwd,
out: buf,
}
-
- cleaner := func(env *Env) interrupt.CleanerFunc {
- return func() error {
- if env.backend != nil {
- err := env.backend.Close()
- env.backend = nil
- return err
- }
- return nil
- }
- }
-
- // Cleanup properly on interrupt
- interrupt.RegisterCleaner(cleaner(testEnv.env))
-
- return testEnv
}