-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlog_test.go
More file actions
47 lines (37 loc) · 907 Bytes
/
Copy pathlog_test.go
File metadata and controls
47 lines (37 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package viaduct
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestInfoWriter(t *testing.T) {
orig := Cli.Stdout
defer func() { Cli.Stdout = orig }()
Cli.Stdout = false
assert.Equal(t, os.Stderr, infoWriter())
Cli.Stdout = true
assert.Equal(t, os.Stdout, infoWriter())
}
func TestEnvBool(t *testing.T) {
const name = "VIADUCT_STDOUT_TEST"
t.Run("unset", func(t *testing.T) {
os.Unsetenv(name)
assert.False(t, envBool(name))
})
t.Run("truthy", func(t *testing.T) {
for _, v := range []string{"1", "t", "true", "TRUE"} {
t.Setenv(name, v)
assert.True(t, envBool(name), v)
}
})
t.Run("falsy", func(t *testing.T) {
for _, v := range []string{"0", "f", "false", "FALSE"} {
t.Setenv(name, v)
assert.False(t, envBool(name), v)
}
})
t.Run("unparseable", func(t *testing.T) {
t.Setenv(name, "nonsense")
assert.False(t, envBool(name))
})
}