Skip to content

Commit cc7d484

Browse files
committed
Fix failing tests and add integration tests
1 parent f4aed76 commit cc7d484

6 files changed

Lines changed: 34 additions & 3 deletions

File tree

commander_linux.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,17 @@ tests:
1414
test docker:
1515
command: ./commander test integration/linux/docker.yaml
1616
stdout: ✓ [docker-host] cat /etc/os-release
17+
exit-code: 0
18+
19+
test directory:
20+
command: ./commander test integration/linux/
21+
stdout:
22+
contains:
23+
- ✓ [nodes.yaml] [ssh-host] it should test ssh host
24+
- ✓ [nodes.yaml] [ssh-host] it should set env variable
25+
- ✓ [nodes.yaml] [ssh-host-default] it should be executed on ssh-host-default
26+
- ✓ [nodes.yaml] [ssh-host] it should test multiple hosts
27+
- ✓ [nodes.yaml] [ssh-host-default] it should test multiple hosts
28+
- ✓ [nodes.yaml] [local] it should test multiple hosts
29+
- ✓ [docker.yaml] [docker-host] cat /etc/os-release
1730
exit-code: 0

commander_unix.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ tests:
6565
- ✓ [local] it should retry failed commands, retries 2
6666
- ✗ [local] it should retry failed commands with an interval, retries 2
6767
exit-code: 1
68+
69+
test directory order:
70+
command: ./commander test --file-order integration/unix/directory_test/
71+
stdout:
72+
lines:
73+
3: ✓ [alpha_test.yaml] [local] sleep test
74+
4: ✓ [beta_test.yaml] [local] ehco hello

examples/commander.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ tests:
1818

1919
it should fail:
2020
command: invalid
21-
stderr: "/bin/sh: 1: invalid: not found"
21+
stderr: "/bin/sh: 1: command invalid: not found"
2222
exit-code: 127
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tests:
2+
sleep test:
3+
command: sleep 2
4+
exit-code: 0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
tests:
2+
ehco hello:
3+
command: echo hello
4+
stdout:
5+
contains:
6+
- hello
7+
exit-code: 0

pkg/app/test_command_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Test_TestCommand(t *testing.T) {
3030
err := TestCommand("commander.yaml", "", AddCommandContext{})
3131

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

4242
if runtime.GOOS == "windows" {
43-
assert.Contains(t, err.Error(), "Error stat my-test.yaml: ")
43+
assert.Contains(t, err.Error(), "Error CreateFile my-test.yaml: ")
4444
} else {
4545
assert.Equal(t, "Error stat my-test.yaml: no such file or directory", err.Error())
4646
}

0 commit comments

Comments
 (0)