GODT-1817: Add tests skips reporter checks to feature tests

Some tests on failure will produce sentry reports. Add a way to skip
the check to see if any reports are produce when we know they will be
triggered.
This commit is contained in:
Leander Beernaert
2023-01-03 10:17:08 +01:00
parent 8c905e4f42
commit 1bdb8b2724
2 changed files with 18 additions and 3 deletions

View File

@ -38,8 +38,9 @@ type reportRecorder struct {
assert *assert.Assertions
reports []reportRecord
lock sync.Locker
isClosed bool
lock sync.Locker
isClosed bool
skipAssert bool
}
func newReportRecorder(tb testing.TB) *reportRecorder {
@ -51,6 +52,10 @@ func newReportRecorder(tb testing.TB) *reportRecorder {
}
}
func (r *reportRecorder) skipAsserts() {
r.skipAssert = true
}
func (r *reportRecorder) add(isException bool, message string, context reporter.Context) {
r.lock.Lock()
defer r.lock.Unlock()
@ -84,7 +89,9 @@ func (r *reportRecorder) close() {
}
func (r *reportRecorder) assertEmpty() {
r.assert.Empty(r.reports)
if !r.skipAssert {
r.assert.Empty(r.reports)
}
}
func (r *reportRecorder) removeMatchingRecords(isException, message, context gomock.Matcher, n int) {
@ -147,3 +154,8 @@ func (r *reportRecorder) ReportExceptionWithContext(data any, context reporter.C
return nil
}
func (s *scenario) skipReporterChecks() error {
s.t.reporter.skipAsserts()
return nil
}