Skip to content

Commit

Permalink
Make version test resilient to new fields (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-bdufour authored Dec 4, 2024
1 parent 8ddd2e2 commit fcd360d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
6 changes: 0 additions & 6 deletions tests_integration/nativeapp/__snapshots__/test_version.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@
list([
dict({
'comment': None,
'dropped_on': None,
'label': '',
'log_level': 'OFF',
'patch': 0,
'review_status': 'NOT_REVIEWED',
'state': 'READY',
'trace_level': 'OFF',
'version': 'V1',
}),
dict({
'comment': None,
'dropped_on': None,
'label': '',
'log_level': 'OFF',
'patch': 1,
'review_status': 'NOT_REVIEWED',
'state': 'READY',
'trace_level': 'OFF',
'version': 'V1',
}),
])
Expand Down
19 changes: 15 additions & 4 deletions tests_integration/nativeapp/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
from tests_integration.test_utils import contains_row_with, row_from_snowflake_session


# A minimal set of fields to compare when checking version output
VERSION_FIELDS_TO_OUTPUT = [
"comment",
"label",
"patch",
"review_status",
"state",
"version",
]


def set_version_in_app_manifest(manifest_path: Path, version: Any, patch: Any = None):
with open(manifest_path, "r") as f:
manifest = safe_load(f)
Expand Down Expand Up @@ -373,10 +384,10 @@ def test_nativeapp_version_create_package_no_magic_comment(
# app package contains version v1 with 2 patches
actual = runner.invoke_with_connection_json(split(list_command))
for row in actual.json:
# Remove date field
row.pop("created_on", None)
# Remove metric_level field
row.pop("metric_level", None)
keys_to_remove = row.keys() - VERSION_FIELDS_TO_OUTPUT
for key in keys_to_remove:
del row[key]

assert actual.json == snapshot


Expand Down

0 comments on commit fcd360d

Please sign in to comment.