Skip to content

Commit 81859d4

Browse files
committed
add separate integration test for testing stdin
1 parent d07bdb5 commit 81859d4

8 files changed

Lines changed: 22 additions & 37 deletions

File tree

cmd/commander/commander.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Tests are always executed in alphabetical order.
5454
Examples:
5555
5656
Directory test:
57-
commander test --dir /your/dir/
57+
test --dir /your/dir/
5858
5959
Stdin test:
6060
cat commander.yaml | commander test -

commander_linux.yaml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,3 @@ tests:
3838
contains:
3939
- Use --dir to test directories with multiple test files
4040
exit-code: 1
41-
42-
test nodes with stdin:
43-
command: cat integration/linux/nodes.yaml | ./commander test -
44-
stdout:
45-
contains:
46-
- ✓ [ssh-host] it should test ssh host
47-
- ✓ [ssh-host] it should set env variable
48-
- ✓ [ssh-host-default] it should be executed on ssh-host-default
49-
- "- [ssh-host-default] it should skip, was skipped"
50-
- "- [ssh-host] it should skip, was skipped"
51-
- "- [local] it should skip, was skipped"
52-
- ✓ [ssh-host] it should test multiple hosts
53-
- ✓ [ssh-host-default] it should test multiple hosts
54-
- ✓ [local] it should test multiple hosts
55-
exit-code: 0

commander_unix.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,9 @@ tests:
134134
- ✓ [local] hello world
135135
exit-code: 0
136136

137-
test retries with stdin:
138-
command: cat integration/unix/retries.yaml | ./commander test -
137+
test stdin input:
138+
command: cat integration/unix/stdin.yaml | ./commander test -
139139
stdout:
140140
contains:
141-
- ✗ [local] echo hello, retries 3
142-
- ✓ [local] it should retry failed commands, retries 2
143-
- ✗ [local] it should retry failed commands with an interval, retries 2
144-
exit-code: 1
141+
- ✓ [local] hello world
142+
exit-code: 0

commander_windows.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ tests:
6464
- ✗ [local] echo hello, retries 3
6565
exit-code: 1
6666

67-
test retries with stdin:
68-
command: type integration\windows\retries.yaml | commander.exe test -
67+
test stdin input:
68+
command: type integration\windows\stdin.yaml | commander.exe test -
6969
stdout:
7070
contains:
71-
- [local] echo hello, retries 3
72-
exit-code: 1
71+
- [local] hello world
72+
exit-code: 0

integration/unix/stdin.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tests:
2+
hello world:
3+
command: echo hello world
4+
stdout: hello world
5+
exit-code: 0

integration/windows/stdin.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tests:
2+
hello world:
3+
command: echo hello world
4+
stdout: hello world
5+
exit-code: 0

pkg/app/test_command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func testStdin(filters runtime.Filters) (runtime.Result, error) {
132132
return runtime.Result{}, err
133133
}
134134

135-
if f.Mode()&os.ModeCharDevice != 0 {
135+
if (f.Mode() & os.ModeCharDevice) != 0 {
136136
return runtime.Result{}, fmt.Errorf("Error: when testing from stdin the command is intended to work with pipes")
137137
}
138138

pkg/app/test_command_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,7 @@ tests:
102102
func Test_TestCommand_Http_Err(t *testing.T) {
103103
err := TestCommand("http://error/not/a/url", TestCommandContext{Dir: false})
104104

105-
if runtime.GOOS == "windows" {
106-
assert.NotNil(t, err)
107-
} else {
108-
assert.NotNil(t, err)
109-
}
105+
assert.NotNil(t, err)
110106
}
111107

112108
func Test_TestCommand_StdIn(t *testing.T) {
@@ -154,11 +150,7 @@ func Test_TestCommand_StdIn_Err(t *testing.T) {
154150

155151
err := TestCommand("-", TestCommandContext{Verbose: false})
156152

157-
if runtime.GOOS == "windows" {
158-
assert.NotNil(t, err)
159-
} else {
160-
assert.NotNil(t, err)
161-
}
153+
assert.NotNil(t, err)
162154
}
163155

164156
func Test_ConvergeResults(t *testing.T) {

0 commit comments

Comments
 (0)