Skip to content

Commit 3a5ac35

Browse files
wesmclaude
andcommitted
Override Fatal/FailNow/Skip on fakeT and remove misleading expectFatal return value
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d362335 commit 3a5ac35

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

internal/query/testfixtures_validation_test.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,21 @@ func (f *fakeT) Fatalf(format string, args ...any) {
3030
f.fatalMsg = fmt.Sprintf(format, args...)
3131
panic(fatalSentinel{f.fatalMsg})
3232
}
33+
func (f *fakeT) Fatal(args ...any) {
34+
f.failed = true
35+
f.fatalMsg = fmt.Sprint(args...)
36+
panic(fatalSentinel{f.fatalMsg})
37+
}
38+
func (f *fakeT) FailNow() {
39+
f.failed = true
40+
panic(fatalSentinel{})
41+
}
42+
func (f *fakeT) Skip(args ...any) {
43+
panic(fatalSentinel{fmt.Sprint(args...)})
44+
}
3345

34-
// expectFatal calls fn and returns true if it triggered fakeT.Fatalf.
35-
func expectFatal(ft *fakeT, fn func()) bool {
46+
// expectFatal calls fn and recovers if it triggered a fakeT fatal/skip.
47+
func expectFatal(ft *fakeT, fn func()) {
3648
defer func() {
3749
if r := recover(); r != nil {
3850
if _, ok := r.(fatalSentinel); !ok {
@@ -41,10 +53,6 @@ func expectFatal(ft *fakeT, fn func()) bool {
4153
}
4254
}()
4355
fn()
44-
return false // no fatal occurred
45-
// unreachable after panic, but if Fatalf fired the deferred
46-
// recover runs and the function returns the zero value (false);
47-
// callers should check ft.failed instead.
4856
}
4957

5058
func TestAddLabel_ValidName(t *testing.T) {

0 commit comments

Comments
 (0)