Skip to content

Commit 91e15c8

Browse files
committed
Migrate WithCustomerBaseCommand test to linux test suite for test coverage purposes
1 parent 2016981 commit 91e15c8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

command_darwin_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
package cmd
22

33
import (
4-
"os/exec"
54
"testing"
65
"time"
76

87
"github.com/stretchr/testify/assert"
98
)
109

11-
func TestCommand_WithCustomBaseCommand(t *testing.T) {
12-
cmd := NewCommand(
13-
"echo $0",
14-
WithCustomBaseCommand(exec.Command("/bin/bash", "-c")),
15-
)
16-
17-
err := cmd.Execute()
18-
assert.Nil(t, err)
19-
// on darwin we use /bin/sh by default test if we're using bash
20-
assert.NotEqual(t, "/bin/sh\n", cmd.Stdout())
21-
assert.Equal(t, "/bin/bash\n", cmd.Stdout())
22-
}
23-
2410
func TestCommand_ExecuteStderr(t *testing.T) {
2511
cmd := NewCommand(">&2 echo hello")
2612

command_linux_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"io/ioutil"
77
"os"
8+
"os/exec"
89
"strings"
910
"testing"
1011
"time"
@@ -157,3 +158,16 @@ func TestCommand_WithContext(t *testing.T) {
157158
assert.NotNil(t, err)
158159
assert.Equal(t, "context deadline exceeded", err.Error())
159160
}
161+
162+
func TestCommand_WithCustomBaseCommand(t *testing.T) {
163+
cmd := NewCommand(
164+
"echo $0",
165+
WithCustomBaseCommand(exec.Command("/bin/bash", "-c")),
166+
)
167+
168+
err := cmd.Execute()
169+
assert.Nil(t, err)
170+
// on darwin we use /bin/sh by default test if we're using bash
171+
assert.NotEqual(t, "/bin/sh\n", cmd.Stdout())
172+
assert.Equal(t, "/bin/bash\n", cmd.Stdout())
173+
}

0 commit comments

Comments
 (0)