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

Changed snapshot assert to field check #1911

Closed
wants to merge 1 commit into from

Conversation

sfc-gh-astus
Copy link
Contributor

@sfc-gh-astus sfc-gh-astus commented Dec 2, 2024

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

Changed snapshot assert to field check.

@sfc-gh-astus sfc-gh-astus requested a review from a team as a code owner December 2, 2024 15:31
Comment on lines 380 to 381
# Remove auditlog_level field
row.pop("auditlog_level", "OFF")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about creating a minimal set of required fields for this snapshot to work and discard all others.
Another option is to create a tuple of fields to discard.

With first case we won't be notice if any new field is added - only removed ones will trigger test to fail
With second we will need to update each time a new field is added.

Finally, do we really need to test for payload in audit log? Do we control the content?
Maybe we could only check if response exists and/or response status?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

@sfc-gh-astus sfc-gh-astus force-pushed the removed-auditlog-level-field branch from 3441036 to e1be2d2 Compare December 3, 2024 10:58
@sfc-gh-astus sfc-gh-astus changed the title Removed auditlog_level from assert Changed snapshot assert to field check Dec 3, 2024
row.pop("metric_level", None)
assert actual.json == snapshot
assert len(actual.json) == 2
_assert_list_of_dicts_contains_key_with_value(actual.json, "patch", 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is significantly weakening the assertion. Since the JSON output is part of the contract, I'd prefer checking that the actual dict is a superset of the expected one instead. Do you want to make the change or would you prefer that we do it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know which fields should I include, treat this as a proposition. Would be great if you could do this 🙏 .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok feel free to close this, I'll submit a PR soon.

@sfc-gh-bdufour
Copy link
Contributor

Replaced with #1918

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.

3 participants