Run tests in pool_test.go as subtests #262
Merged
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.
This updates the "parent" test in
pool_test.go
to utilize the go testing framework's concept of subtests.A new database is created for each subtest. This removes the need for each test to have its own specific clean up, and guarantees each test will have a clean database which is not contaminated by any previous tests. The performance penalty for repeatedly creating new databases is negligible.
Utilizing subtests allows the testing framework to provide more detailed feedback about the test run. Information about each subtest is logged, rather than just one log line for the parent test.
Managing the creation, cleaning and deleting of test databases in the "parent" test, outside of the "child" test files, is going to be useful for #257 because it is a good step towards allowing the test files to be database agnostic.
As an immediate example of how the detailed feedback can be useful, the example below shows that of the 10 second runtime, almost all of it is consumed by
testClient
. Previously this fact was hidden because it just appeared that the parent testTestPool
was taking 10 seconds.Log before (click to expand)
Log after (click to expand)
Also:
pool_test.go
. These can be run standalone with no issues.emptyBucket
func from production code into test code (it is only used by tests)