Skip to content

Commit

Permalink
Fix failing tests and add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhitt committed May 2, 2020
1 parent f4aed76 commit cc7d484
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
13 changes: 13 additions & 0 deletions commander_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,17 @@ tests:
test docker:
command: ./commander test integration/linux/docker.yaml
stdout: ✓ [docker-host] cat /etc/os-release
exit-code: 0

test directory:
command: ./commander test integration/linux/
stdout:
contains:
- ✓ [nodes.yaml] [ssh-host] it should test ssh host
- ✓ [nodes.yaml] [ssh-host] it should set env variable
- ✓ [nodes.yaml] [ssh-host-default] it should be executed on ssh-host-default
- ✓ [nodes.yaml] [ssh-host] it should test multiple hosts
- ✓ [nodes.yaml] [ssh-host-default] it should test multiple hosts
- ✓ [nodes.yaml] [local] it should test multiple hosts
- ✓ [docker.yaml] [docker-host] cat /etc/os-release
exit-code: 0
7 changes: 7 additions & 0 deletions commander_unix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@ tests:
- ✓ [local] it should retry failed commands, retries 2
- ✗ [local] it should retry failed commands with an interval, retries 2
exit-code: 1

test directory order:
command: ./commander test --file-order integration/unix/directory_test/
stdout:
lines:
3: ✓ [alpha_test.yaml] [local] sleep test
4: ✓ [beta_test.yaml] [local] ehco hello
2 changes: 1 addition & 1 deletion examples/commander.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ tests:

it should fail:
command: invalid
stderr: "/bin/sh: 1: invalid: not found"
stderr: "/bin/sh: 1: command invalid: not found"
exit-code: 127
4 changes: 4 additions & 0 deletions integration/unix/directory_test/alpha_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tests:
sleep test:
command: sleep 2
exit-code: 0
7 changes: 7 additions & 0 deletions integration/unix/directory_test/beta_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tests:
ehco hello:
command: echo hello
stdout:
contains:
- hello
exit-code: 0
4 changes: 2 additions & 2 deletions pkg/app/test_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func Test_TestCommand(t *testing.T) {
err := TestCommand("commander.yaml", "", AddCommandContext{})

if runtime.GOOS == "windows" {
assert.Contains(t, err.Error(), "Error stat commander.yaml:")
assert.Contains(t, err.Error(), "Error CreateFile commander.yaml:")
} else {
assert.Equal(t, "Error stat commander.yaml: no such file or directory", err.Error())
}
Expand All @@ -40,7 +40,7 @@ func Test_TestCommand_ShouldUseCustomFile(t *testing.T) {
err := TestCommand("my-test.yaml", "", AddCommandContext{})

if runtime.GOOS == "windows" {
assert.Contains(t, err.Error(), "Error stat my-test.yaml: ")
assert.Contains(t, err.Error(), "Error CreateFile my-test.yaml: ")
} else {
assert.Equal(t, "Error stat my-test.yaml: no such file or directory", err.Error())
}
Expand Down

0 comments on commit cc7d484

Please sign in to comment.