-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(allsrv): refactor v2 tests with table tests
There are a few things to note here: 1. We are making use of table tests. With minimal "relearning" we can extend the usecases to accomodate the growing needs of the server. 2. The test cases make use of some simple helper funcs to make the tests more readable. Tests like these act as documentation for future contributors. This should not be taken lightly... as the future you, will thank you :-). 3. We make use of a _want func_ here. This might be new to some folks, but this is preferred when creating table tests for any UUT that returns more than a simple output (i.e. strings/ints/structs). With the _want func_, we get much improved test error stack traces. The entire existence of the test is within the usecase. The common test bootstrapping is found within the `t.Run` function body, however, it is not a place we will find error traces as there is no where for it to fail `:thinker:`. We're able to run more assertions/check than what the server responds with. For example, checking that the database does not contain a record that should not exist. However, all that pales in comparison to how much this simplifies the logic of the test. You may have run into a situation where table tests are paired with a incredibly complex test setup, interleaving multiple codepaths for setup and assertions. This is a heavy burden for the next person to look at this code. That next person, may be you... look out for you. With the improved test suite, we can make some foundational fixes to align with JSON-API. The previous implementation did not use a `Data` type for the request body but with some tests in place, we can validate the desired shape. Now that we have a solid foundation to build from, we can extend our use case further to support the read/update/delete APIs. Branch off of this commit and attempt to add these new APIs.
- Loading branch information
Showing
3 changed files
with
304 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.