Skip to content

Commit af4e60d

Browse files
committed
Add stdout and stderr type validation
1 parent 45fe2fb commit af4e60d

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# v1.1.0
22

33
- Add `not-contains` assertion on `stdout` and `stderr`
4+
- Add validation for invalid data types in `stdout` and `stderr` assertions
5+
- More logging for `--verbose` option on the `test` command
46

57
# v1.0.1
68

pkg/suite/yaml_suite.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ func (y *YAMLConfig) convertToExpectedOut(value interface{}) runtime.ExpectedOut
211211
}
212212
}
213213
break
214+
215+
case nil:
216+
break
217+
default:
218+
panic(fmt.Sprintf("Failed to parse Stdout or Stderr with values: %v", value))
214219
}
215220

216221
return exp

pkg/suite/yaml_suite_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,22 @@ tests:
225225

226226
_ = ParseYAML(yaml)
227227
}
228+
229+
func TestYamlSuite_ShouldFailIfArrayIsGivenToExpectedOut(t *testing.T) {
230+
defer func() {
231+
r := recover()
232+
if r != nil {
233+
assert.Contains(t, r, "Failed to parse Stdout or Stderr with values: [yeah]")
234+
}
235+
assert.NotNil(t, r)
236+
}()
237+
238+
yaml := []byte(`
239+
tests:
240+
echo hello:
241+
stdout:
242+
- yeah
243+
`)
244+
245+
_ = ParseYAML(yaml)
246+
}

0 commit comments

Comments
 (0)