Introduce new testing layout #229
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.
Overview
The project currently has a robust test suite that exercises most of the functionalities against the actual http API. This is not very suitable to iterate fast on the code, thus this PR introduces the concept of unit tests in addition to the existing suite that will stay as it is but will be marked as "integration tests".
Implementation
Integration test functions will contain the string
Integration
in the name, so that the suite can be run withgo test -run integration ./...
. Integration tests will be skipped when running unit tests and we use theshort
option from the Go standard lib to make this easy: each test function will begin like this:This way, unit tests will be run with just
go test -short ./...
To make easier for contributors and the CI to run either of the suites, or both in sequence, a task runner was added.
task
is written in Go and can be easily installed by justgo get
so it should be fair to ask developers to have it in their dev env. Available tasks are defined in theTaskfile.yml
file, with this PR you can dotask test-unit
to run all the unit tests, or (for example)task test-unit TARGETS=./auth
to run all the unit tests for theauth
package only.task test-integration
is symmetric whiletask test
will run both integration and unit tests.Note that
go test ./...
will keep running all the tests so the use oftask
is not mandatory.