Skip to content

Commit 34c15d3

Browse files
authored
Merge pull request #75 from SimonBaeumer/more-logging
More logging
2 parents b6c5399 + af4e60d commit 34c15d3

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-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/runtime/runtime.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ func runTest(test TestCase) TestResult {
157157
}
158158

159159
log.Println("title: '"+test.Title+"'", " Command: ", cut.Cmd)
160+
log.Println("title: '"+test.Title+"'", " Directory: ", cut.Dir)
161+
log.Println("title: '"+test.Title+"'", " Env: ", cut.Env)
160162

161163
// Write test result
162164
test.Result = CommandResult{

pkg/runtime/validator.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package runtime
33
import (
44
"fmt"
55
"github.com/SimonBaeumer/commander/pkg/matcher"
6+
"log"
67
"strings"
78
)
89

@@ -24,7 +25,9 @@ func newValidationResult(m matcher.MatcherResult) ValidationResult {
2425
func Validate(test TestCase) TestResult {
2526
equalMatcher := matcher.NewMatcher(matcher.Equal)
2627

28+
log.Println("title: '"+test.Title+"'", " Stdout-Expected: ", test.Expected.Stdout)
2729
matcherResult := validateExpectedOut(test.Result.Stdout, test.Expected.Stdout)
30+
log.Println("title: '"+test.Title+"'", " Stdout-Result: ", matcherResult.Success)
2831
if !matcherResult.Success {
2932
return TestResult{
3033
ValidationResult: newValidationResult(matcherResult),
@@ -33,7 +36,9 @@ func Validate(test TestCase) TestResult {
3336
}
3437
}
3538

39+
log.Println("title: '"+test.Title+"'", " Stderr-Expected: ", test.Expected.Stderr)
3640
matcherResult = validateExpectedOut(test.Result.Stderr, test.Expected.Stderr)
41+
log.Println("title: '"+test.Title+"'", " Stderr-Result: ", matcherResult.Success)
3742
if !matcherResult.Success {
3843
return TestResult{
3944
ValidationResult: newValidationResult(matcherResult),
@@ -42,7 +47,9 @@ func Validate(test TestCase) TestResult {
4247
}
4348
}
4449

50+
log.Println("title: '"+test.Title+"'", " Exit-Expected: ", test.Expected.ExitCode)
4551
matcherResult = equalMatcher.Match(test.Result.ExitCode, test.Expected.ExitCode)
52+
log.Println("title: '"+test.Title+"'", " Exit-Result: ", matcherResult.Success)
4653
if !matcherResult.Success {
4754
return TestResult{
4855
ValidationResult: newValidationResult(matcherResult),

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)