Validate validates the test results with the expected values The test should hold the result and expected to validate the result
(test TestCase)
| 24 | // Validate validates the test results with the expected values |
| 25 | // The test should hold the result and expected to validate the result |
| 26 | func Validate(test TestCase) TestResult { |
| 27 | equalMatcher := matcher.NewMatcher(matcher.Equal) |
| 28 | |
| 29 | log.Println("title: '"+test.Title+"'", " Stdout-Expected: ", test.Expected.Stdout) |
| 30 | matcherResult := validateExpectedOut(test.Result.Stdout, test.Expected.Stdout) |
| 31 | log.Println("title: '"+test.Title+"'", " Stdout-Result: ", matcherResult.Success) |
| 32 | if !matcherResult.Success { |
| 33 | return TestResult{ |
| 34 | ValidationResult: newValidationResult(matcherResult), |
| 35 | TestCase: test, |
| 36 | FailedProperty: Stdout, |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | log.Println("title: '"+test.Title+"'", " Stderr-Expected: ", test.Expected.Stderr) |
| 41 | matcherResult = validateExpectedOut(test.Result.Stderr, test.Expected.Stderr) |
| 42 | log.Println("title: '"+test.Title+"'", " Stderr-Result: ", matcherResult.Success) |
| 43 | if !matcherResult.Success { |
| 44 | return TestResult{ |
| 45 | ValidationResult: newValidationResult(matcherResult), |
| 46 | TestCase: test, |
| 47 | FailedProperty: Stderr, |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | log.Println("title: '"+test.Title+"'", " Exit-Expected: ", test.Expected.ExitCode) |
| 52 | matcherResult = equalMatcher.Match(test.Result.ExitCode, test.Expected.ExitCode) |
| 53 | log.Println("title: '"+test.Title+"'", " Exit-Result: ", matcherResult.Success) |
| 54 | if !matcherResult.Success { |
| 55 | return TestResult{ |
| 56 | ValidationResult: newValidationResult(matcherResult), |
| 57 | TestCase: test, |
| 58 | FailedProperty: ExitCode, |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return TestResult{ |
| 63 | ValidationResult: newValidationResult(matcherResult), |
| 64 | TestCase: test, |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | func validateExpectedOut(got string, expected ExpectedOut) matcher.MatcherResult { |
| 69 | var m matcher.Matcher |