ref(test): Add TestManager
struct for uniform test setup
#2252
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.
Add
TestManager
to manage setting up Mocks and Trycmd tests. TheTestManager
's API makes it easier to achieve uniform setup of our integration tests. This will also make bumping to new Mockito (see #2223) easier, since the new Mockito API will require manually setting up a mock server which needs to stay alive for the duration of the test. Having a TestManager will abstract away the management of this server, so the calling code does not need to worry about this.All tests have been migrated to the new
TestManager
API with this change, as we are also removing the old API. For the most part, all tests should be verifying the same things as they were before this change. However, there are two intentional behavior changes to the tests with the new API:register_test
function injected theSENTRY_AUTH_TOKEN
environment variable. To run a test without an auth token, there was a separateregister_test_without_token
function which did not inject this environment variable. The new API's defaultregister_trycmd_test
function does not inject theSENTRY_AUTH_TOKEN
environment variable. To get the environment variable, you need to callwith_default_token
method on theTrycmdTestManager
. This change adds thewith_default_token
call only to those tests which would fail without theSENTRY_AUTH_TOKEN
environment variable, meaning that several tests where the token was previously present no longer have it, since they apparently don't need the token.common_upload_endpoints
, even when other mocks were also present. Now, theTestManager
exposes anassert_mock_endpoints
function which asserts all the mock endpoints on the manager. This change required a change to some of the additional mocks. One mock's path was made more specific (since it was called with a more specific path), and another mock was deleted since it was never called.