diff options
Diffstat (limited to 'commands/execenv/env_test.go')
-rw-r--r-- | commands/execenv/env_test.go | 54 |
1 files changed, 7 insertions, 47 deletions
diff --git a/commands/execenv/env_test.go b/commands/execenv/env_test.go index 3a59f187..3fc6e581 100644 --- a/commands/execenv/env_test.go +++ b/commands/execenv/env_test.go @@ -7,55 +7,15 @@ import ( "github.com/stretchr/testify/require" ) -func TestGetIOMode(t *testing.T) { +func TestIsTerminal(t *testing.T) { + // easy way to get a reader and a writer r, w, err := os.Pipe() require.NoError(t, err) - testcases := []struct { - name string - in *os.File - out *os.File - expInMode bool - expOutMode bool - }{ - { - name: "neither redirected", - in: os.Stdin, - out: os.Stdout, - expInMode: false, - expOutMode: false, - }, - { - name: "in redirected", - in: w, - out: os.Stdout, - expInMode: true, - expOutMode: false, - }, - { - name: "out redirected", - in: os.Stdin, - out: r, - expInMode: false, - expOutMode: true, - }, - { - name: "both redirected", - in: w, - out: r, - expInMode: true, - expOutMode: true, - }, - } + require.False(t, isTerminal(r)) + require.False(t, isTerminal(w)) - for i := range testcases { - testcase := testcases[i] - - t.Run(testcase.name, func(t *testing.T) { - t.Parallel() - - env := NewEnv() - require.NotNil(t, env) - }) - } + // golang's testing framework replaces os.Stdin and os.Stdout, so the following doesn't work here + // require.True(t, isTerminal(os.Stdin)) + // require.True(t, isTerminal(os.Stdout)) } |