Standardise entry points for Complement tests #669
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.
Every test package that wants to use Complement needs some bootstrapping boilerplate code to do things like read the env vars and clean up old containers in case of an ungraceful shutdown. There is a convenient
TestMain
function which is part of standard Go tests which we can use for this.We also had a helper function called
Deploy
which would deploy a set of containers and return thedocker.Deployment
for tests to use. This helper function is actually boilerplate as well, but has still historically been defined for each test package unnecessarily.This PR cleans up these entry points in the following way:
helpers
package to the top-levelcomplement
package. Why: this signals to test writers where to look when they want to hook into Complement machinery as it serves as the entry point functions. This ends up reading very nicely asdeployment := complement.Deploy(t, b.BlueprintAlice)
.Deploy(...)
which just called the previous line.This now means that out-of-repo tests (which need to call
somepackage.Deploy
) and in-repo tests look identical, and bootstrapping boilerplate is as small as possible: