test: Add tests and comments to better document any typed data structures
#1498
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.
Summary:
While working on unit tests for the
mutatefunction forAuthorized Viewswe needed to determine the structure of the first argument passed intomutate. Currently the type of the first argument isEntrywhich is just an alias forany, but this is problematic because we can't expect any data structure for this argument. In fact, this method will only work properly if this argument is in a very specific format. Knowing this exact format is important when writing unit tests for mutate.In this PR we add comments to the source code that describe the shape of the first mutate argument by describing the
Entrydata type and provide some tests that demonstrate howmutateandinsertcan be used.Next steps:
In the future we may want to change the
Entrytype to be more specific so that users can only usemutatein the way it was intended to be used or else they will see a compiler error. This would be a breaking change though so it is a safer first step just to add some comments.