Skip to content

Commit e2003ee

Browse files
committed
Added unit test
1 parent 99208a8 commit e2003ee

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

haproxy/haproxy_cmd/cmd_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package haproxy_cmd
2+
3+
import (
4+
"testing"
5+
6+
"github.com/criteo/haproxy-consul-connect/lib"
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func Test_runCommand_ok(t *testing.T) {
11+
t.Parallel()
12+
sd := lib.NewShutdown()
13+
cmd, err := runCommand(sd, "ls", ".")
14+
assert.NoError(t, err)
15+
cmd.Wait()
16+
}
17+
18+
func Test_runCommand_nok_wrong_path(t *testing.T) {
19+
t.Parallel()
20+
sd := lib.NewShutdown()
21+
cmd, err := runCommand(sd, "/path/to/nowhere/that/can/be/found/myExec", "--help")
22+
assert.NotNil(t, err)
23+
assert.Contains(t, err.Error(), "no such file or directory")
24+
assert.Nil(t, cmd)
25+
}

0 commit comments

Comments
 (0)