Repository navigation
Keep a failed test's database on request - #6
Merged
Merged
Conversation
Off by default, every test database is dropped. With testdb.WithKeepOnFailure(), or TESTDB_KEEP_ON_FAILURE=1 for a whole run, a failed test's database is left in place and the test log gives a psql command for it; passing tests still clean up. TestDatabase.Keep exposes the mechanism for the low-level API. Kept in the test's log rather than defaulting to keep (as pgtestdb does) so CI never accumulates databases nobody will look at.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By default every test database is dropped, pass or fail. This adds a switch to keep a failed test's database so its data can be inspected:
TESTDB_KEEP_ON_FAILURE=1 go test ./... -run TestCheckouttestdb.WithKeepOnFailure()is the in-code form;TESTDB_KEEP_ON_FAILURE(1/true/yes/on) turns it on for a run without touching code.postgres's cleanup whent.Failed().TestDatabase.Keep()is the mechanism, exposed for the low-leveltestdb.Newpath where you decide yourself.Tests cover: kept on failure (option and env), dropped on success even with the option, dropped on failure without it, the log line's content, and that
Keepstill releases the provider's resources.