Skip to content
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

database: Minor test cleanup. #3147

Merged
merged 2 commits into from
Jun 15, 2023
Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Jun 14, 2023

This modifies several of the tests in the database module to use t.TempDir and marks several of the funcs that are used as helpers as test helpers so any failures will be attributed to the caller as opposed to the methods themselves.

The directory t.TempDir creates is automatically removed when the test and all its subtests complete.

Finally, it changes out some of the cleanup logic for closing the database to use t.Cleanup instead of defer to ensure the close happens during test cleanup after the directories created by t.TempDir have been removed.

@davecgh davecgh added the test coverage Discussion and pull requests for improving test coverage. label Jun 14, 2023
@davecgh davecgh added this to the 1.9.0 milestone Jun 14, 2023
@davecgh davecgh force-pushed the database_test_cleanup branch from 0c54fb8 to 3397354 Compare June 15, 2023 06:01
davecgh added 2 commits June 15, 2023 15:05
This marks several of the funcs that are used as helpers as test
helpers so any failures will be attributed to the caller as opposed to
the methods themselves.
This modifies several of the tests to use t.TempDir.  The directory it
creates is automatically removed when the test and all its subtests
complete.

It also changes out some of the cleanup logic for closing the database
to use t.Cleanup instead of defer to ensure the close happens during
test cleanup after the directories created by t.TempDir have been
removed.
@davecgh davecgh force-pushed the database_test_cleanup branch from 3397354 to 05e66dc Compare June 15, 2023 20:05
@davecgh davecgh merged commit 05e66dc into decred:master Jun 15, 2023
@davecgh davecgh deleted the database_test_cleanup branch June 15, 2023 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test coverage Discussion and pull requests for improving test coverage.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants