aboutsummaryrefslogtreecommitdiffstats
path: root/commands/env_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/env_test.go')
-rw-r--r--commands/env_test.go61
1 files changed, 0 insertions, 61 deletions
diff --git a/commands/env_test.go b/commands/env_test.go
deleted file mode 100644
index 346024ab..00000000
--- a/commands/env_test.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package commands_test
-
-import (
- "bytes"
- "context"
- "flag"
- "io/ioutil"
- "os"
- "testing"
-
- "github.com/spf13/cobra"
- "github.com/stretchr/testify/require"
-
- "github.com/MichaelMure/git-bug/commands"
- "github.com/MichaelMure/git-bug/repository"
-)
-
-var update = flag.Bool("update", false, "pass -update to the test runner to update golden files")
-
-type testEnv struct {
- cwd string
- repo *repository.GoGitRepo
- cmd *cobra.Command
- out *bytes.Buffer
-}
-
-func newTestEnv(t *testing.T) *testEnv {
- t.Helper()
-
- cwd, err := ioutil.TempDir("", "")
- require.NoError(t, err)
- t.Cleanup(func() {
- require.NoError(t, os.RemoveAll(cwd))
- })
-
- repo, err := repository.InitGoGitRepo(cwd, commands.GitBugNamespace)
- require.NoError(t, err)
- t.Cleanup(func() {
- require.NoError(t, repo.Close())
- })
-
- out := new(bytes.Buffer)
- cmd := commands.NewRootCommand()
- cmd.SetArgs([]string{})
- cmd.SetErr(out)
- cmd.SetOut(out)
-
- return &testEnv{
- cwd: cwd,
- repo: repo,
- cmd: cmd,
- out: out,
- }
-}
-
-func (e *testEnv) Execute(t *testing.T) {
- t.Helper()
-
- ctx := context.WithValue(context.Background(), "cwd", e.cwd)
- require.NoError(t, e.cmd.ExecuteContext(ctx))
-}