Skip to content
This repository was archived by the owner on May 4, 2026. It is now read-only.

services: stop tests before panicking#347

Merged
trekhopton merged 1 commit into
masterfrom
no-test-panic
Jan 7, 2026
Merged

services: stop tests before panicking#347
trekhopton merged 1 commit into
masterfrom
no-test-panic

Conversation

@trekhopton
Copy link
Copy Markdown
Collaborator

This was done because the test would panic occasionally. First step is to not let it panic.

The panic I'm referring to is #346 .

This was done because the test would panic occasionally. First step is to not let it panic.
@trekhopton trekhopton merged commit e8f330e into master Jan 7, 2026
2 checks passed
@Saxon1
Copy link
Copy Markdown

Saxon1 commented Jan 9, 2026

Maybe dumb question but what's the problem with it panicing ? It'll juts fail the current tetst right ?

@trekhopton
Copy link
Copy Markdown
Collaborator Author

Maybe dumb question but what's the problem with it panicing ? It'll juts fail the current tetst right ?

Yes, but that's what t.Fatalf is for imo, if code panics it usually indicates to me that something in the code is wrong and something unexpected is happening. It's better imo if test output is clear, and panics make things messy.

It's like you're trying to continue testing with invalid data because there's been an error upstream but the test was allowed to continue.

@Saxon1
Copy link
Copy Markdown

Saxon1 commented Jan 13, 2026

Maybe dumb question but what's the problem with it panicing ? It'll juts fail the current tetst right ?

Yes, but that's what t.Fatalf is for imo, if code panics it usually indicates to me that something in the code is wrong and something unexpected is happening. It's better imo if test output is clear, and panics make things messy.

It's like you're trying to continue testing with invalid data because there's been an error upstream but the test was allowed to continue.

hhhmm I don't think that's completely right. t.Error is when there's been a problem but you can continue the test, and t.Fatal is for when it wouldn't be meaningful to continue the test. I don't think t.Fatal should be used to avoid panics. I think panics inside functions/methods your testing is absolutely fine and you're trying to find those. Basically I'm saying your reasons for the change might be slightly off ?

I think your change is OK anyways for other reasons; in most of the places you're now using t.Fatal make sense because it wouldn't really be meaningful to continue those tests with t.Error

@trekhopton
Copy link
Copy Markdown
Collaborator Author

Maybe dumb question but what's the problem with it panicing ? It'll juts fail the current tetst right ?

Yes, but that's what t.Fatalf is for imo, if code panics it usually indicates to me that something in the code is wrong and something unexpected is happening. It's better imo if test output is clear, and panics make things messy.
It's like you're trying to continue testing with invalid data because there's been an error upstream but the test was allowed to continue.

hhhmm I don't think that's completely right. t.Error is when there's been a problem but you can continue the test, and t.Fatal is for when it wouldn't be meaningful to continue the test. I don't think t.Fatal should be used to avoid panics. I think panics inside functions/methods your testing is absolutely fine and you're trying to find those. Basically I'm saying your reasons for the change might be slightly off ?

I think your change is OK anyways for other reasons; in most of the places you're now using t.Fatal make sense because it wouldn't really be meaningful to continue those tests with t.Error

Yeah, it wouldn't be meaningful to continue the tests, I agree. That's my reason.

I get that we want to find panics if they're cause by code that we're testing, but the test code shouldn't be panicking because they didn't stop at the right time.

@Saxon1
Copy link
Copy Markdown

Saxon1 commented Jan 13, 2026

Maybe dumb question but what's the problem with it panicing ? It'll juts fail the current tetst right ?

Yes, but that's what t.Fatalf is for imo, if code panics it usually indicates to me that something in the code is wrong and something unexpected is happening. It's better imo if test output is clear, and panics make things messy.
It's like you're trying to continue testing with invalid data because there's been an error upstream but the test was allowed to continue.

hhhmm I don't think that's completely right. t.Error is when there's been a problem but you can continue the test, and t.Fatal is for when it wouldn't be meaningful to continue the test. I don't think t.Fatal should be used to avoid panics. I think panics inside functions/methods your testing is absolutely fine and you're trying to find those. Basically I'm saying your reasons for the change might be slightly off ?
I think your change is OK anyways for other reasons; in most of the places you're now using t.Fatal make sense because it wouldn't really be meaningful to continue those tests with t.Error

Yeah, it wouldn't be meaningful to continue the tests, I agree. That's my reason.

I get that we want to find panics if they're cause by code that we're testing, but the test code shouldn't be panicking because they didn't stop at the right time.

Yes agreed, the testing code shouldn't be panicing 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants