Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incrementing test version without any change #3566

Merged
merged 1 commit into from Jan 25, 2024
Merged

Conversation

schoren
Copy link
Collaborator

@schoren schoren commented Jan 25, 2024

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:

type: Test
spec:
  id: test1234
  name: Untitled
  trigger:
    type: http
    httpRequest:
      method: GET
      url: https://google.com
      headers:
      - key: Content-Type
        value: application/json

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 a nil slice (JSON encoded as "null") and the other one is an empty slice (JSON encoded as []). So the final check was if "nil" == "[]", which is an incorrect interpretation.

To fix this, we use a getter function to normalize nil specs as empty slices.

Changes

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

Loom video

Add your loom video here if your work can be visualized

@schoren schoren requested a review from xoscar January 25, 2024 20:14
@schoren schoren merged commit 0363b09 into main Jan 25, 2024
37 checks passed
@schoren schoren deleted the fix-version-check branch January 25, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants