Merge "Switch the namespace tests to fully use test fixtures"

This commit is contained in:
Treehugger Robot
2022-05-11 22:43:28 +00:00
committed by Gerrit Code Review
2 changed files with 443 additions and 469 deletions

View File

@@ -586,6 +586,18 @@ func FixtureExpectsAllErrorsToMatchAPattern(patterns []string) FixtureErrorHandl
})
}
// FixtureExpectsOneErrorPattern returns an error handler that will cause the test to fail
// if there is more than one error or the error does not match the pattern.
//
// If the test fails this handler will call `result.FailNow()` which will exit the goroutine within
// which the test is being run which means that the RunTest() method will not return.
func FixtureExpectsOneErrorPattern(pattern string) FixtureErrorHandler {
return FixtureCustomErrorHandler(func(t *testing.T, result *TestResult) {
t.Helper()
CheckErrorsAgainstExpectations(t, result.Errs, []string{pattern})
})
}
// FixtureCustomErrorHandler creates a custom error handler
func FixtureCustomErrorHandler(function func(t *testing.T, result *TestResult)) FixtureErrorHandler {
return simpleErrorHandler{

File diff suppressed because it is too large Load Diff