File tree Expand file tree Collapse file tree 2 files changed +14
-14
lines changed
Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change 11package cmd
22
33import (
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-
2410func TestCommand_ExecuteStderr (t * testing.T ) {
2511 cmd := NewCommand (">&2 echo hello" )
2612
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments