aboutsummaryrefslogtreecommitdiffstats
path: root/commands/execenv/env_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2023-01-17 20:02:31 +0100
committerMichael Muré <batolettre@gmail.com>2023-01-17 20:02:31 +0100
commitf011452a2d7ed26d522896a1dab090d7ede05cf1 (patch)
tree7d86adb1fb9d290f5acfa3b36f606f4e24f01fa7 /commands/execenv/env_test.go
parenta73640150d8f5c8492140f9d81e7b84542b95763 (diff)
downloadgit-bug-f011452a2d7ed26d522896a1dab090d7ede05cf1.tar.gz
execenv: move terminal detection to Out, introduce the compagnion In
Diffstat (limited to 'commands/execenv/env_test.go')
-rw-r--r--commands/execenv/env_test.go54
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))
}