-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make mockT.Fatal halt execution #396
Conversation
Maybe instead you could add |
You could alternatively just switch to this package: https://github.com/mitchellh/go-testing-interface |
@paultyng We can switch to it in V2. This PR doesn't remove anything it fixes a bug where a mock test continues execution after |
@paultyng would I be reimplementing |
Yeah i guess in this context I'd say fix the mock, not change the code to be incorrect in a normal context. Additionally you could change these returns to panics, as they should not be hit in a normal situation? |
You could simulate it for testing via panic/recover instead of using exit. |
@paultyng fixed with recover/panic |
remove returns after t.Fatal
605b666
to
cdd4c2d
Compare
Once this is cherry-picked to V2 it will fix a test bug in #357 |
helper/resource/testing_test.go
Outdated
|
||
func() { | ||
defer func() { | ||
recover() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to sanity check here, i would ensure the recover
value is "mockT.Fatal"
or something and not an unrelated panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thank you for chasing this down
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
The current
mockT
did not halt execution onFatal
, this led to a test failure as the SDK code expectst.Fatal
to halt execution. This introduces a panic and recover to fix the unit test. Future use of the mock (if there are any) should follow the same pattern