diff options
Diffstat (limited to 'internal/test/recorder.go')
-rw-r--r-- | internal/test/recorder.go | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/internal/test/recorder.go b/internal/test/recorder.go index 35ddb0d01..7d9f4a5f2 100644 --- a/internal/test/recorder.go +++ b/internal/test/recorder.go @@ -5,24 +5,46 @@ import ( "testing" ) +const ( + RecorderFailNow int = iota +) + type recorder struct { testing.TB - fail func(string) - fatal func(string) + fail func(string) + fatal func(string) + failed bool +} + +func (r *recorder) Error(args ...any) { + r.failed = true + r.fail(fmt.Sprint(args...)) } func (r *recorder) Errorf(format string, args ...any) { + r.failed = true r.fail(fmt.Sprintf(format, args...)) } -func (r *recorder) Fatalf(format string, args ...any) { - r.fatal(fmt.Sprintf(format, args...)) +func (r *recorder) Fail() { + r.failed = true +} + +func (r *recorder) FailNow() { + r.failed = true + panic(RecorderFailNow) +} + +func (r *recorder) Failed() bool { + return r.failed } func (r *recorder) Fatal(args ...any) { + r.failed = true r.fatal(fmt.Sprint(args...)) } -func (r *recorder) Error(args ...any) { - r.fail(fmt.Sprint(args...)) +func (r *recorder) Fatalf(format string, args ...any) { + r.failed = true + r.fatal(fmt.Sprintf(format, args...)) } |