Skip to content

Commit

Permalink
Avoid false-positive test failure with schema updates (#3817)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Oct 6, 2023
1 parent 30b1bc9 commit e710099
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/ansiblelint/schemas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int:
get_schema.cache_clear()
else:
store_file.touch()
changed = 1
return changed


Expand Down
6 changes: 3 additions & 3 deletions test/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_refresh_schemas() -> None:
assert refresh_schemas(min_age_seconds=3600 * 24 * 365 * 10) == 0
sleep(1)
# this should disable the cache and force an update
assert refresh_schemas(min_age_seconds=0) == 1
assert refresh_schemas(min_age_seconds=0) == 0
sleep(1)
# should be cached now
assert refresh_schemas(min_age_seconds=10) == 0
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_request_timeouterror_handling(
error_msg = "Simulating handshake operation time out."
mock_request.urlopen.side_effect = urllib.error.URLError(TimeoutError(error_msg))
with caplog.at_level(logging.DEBUG):
assert refresh_schemas(min_age_seconds=0) == 1
assert refresh_schemas(min_age_seconds=0) == 0
mock_request.urlopen.assert_called()
assert "Skipped schema refresh due to unexpected exception: " in caplog.text
assert error_msg in caplog.text
Expand All @@ -75,7 +75,7 @@ def test_schema_refresh_cli() -> None:
capture_output=True,
text=True,
)
assert proc.returncode == 0
assert proc.returncode == 0, proc


def test_validate_file_schema() -> None:
Expand Down

0 comments on commit e710099

Please sign in to comment.