fix: incrementing test version without any change #3566
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.
This PR fixes a bug with how version change is calculated. Our algorithm checks for the relevant parts of the test and compares the JSON encoded version of each, since that's the easiest way to do it. The problem is that some times, empty fields can have different representations in go, which result in different JSON encoded values.
In this particular case, every time I applied this test:
it was creating a new version, which is incorrect. The problem was that when comparing the new version with the one from DB, both have empty
Spec
, but one is anil
slice (JSON encoded as"null"
) and the other one is an empty slice (JSON encoded as[]
). So the final check wasif "nil" == "[]"
, which is an incorrect interpretation.To fix this, we use a getter function to normalize nil specs as empty slices.
Changes
Fixes
Checklist
Loom video
Add your loom video here if your work can be visualized