Skip to content

Commit

Permalink
fix(updater): fix update summary with up-to-date configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fyhertz committed Jan 10, 2022
1 parent 4f56067 commit 8048240
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ops2deb/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def update(
for r in latest_releases
if r.is_new
]
output_path.write_text("\n".join(lines) + "\n")
output_path.write_text("\n".join(lines + [""]))

_, fetcher_errors = separate_successes_from_errors(fetch_results.values())
if fetcher_errors or updater_errors:
Expand Down
41 changes: 41 additions & 0 deletions tests/test_ops2deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@
- mv great-app {{src}}/usr/bin/great-app
"""

mock_configuration_up_to_date = """\
- name: great-app
version: 1.1.1
revision: 2
arch: all
summary: Great package
description: A detailed description of the great package.
fetch:
url: http://testserver/{{version}}/great-app.tar.gz
sha256: f1be6dd36b503641d633765655e81cdae1ff8f7f73a2582b7468adceb5e212a9
script:
- mv great-app {{src}}/usr/bin/great-app
"""


mock_configuration_with_invalid_archive_checksum = """\
- name: bad-app
version: 1.0.0
Expand Down Expand Up @@ -276,6 +291,32 @@ def test_ops2deb_update_should_succeed_with_valid_configuration(tmp_path, call_o
assert configuration[0].fetch.sha256 == sha256


def test_ops2deb_update_should_create_summary_when_called_with_output_file(
tmp_path, call_ops2deb
):
output_file = tmp_path / "summary.log"
call_ops2deb(
"update",
"--output-file",
str(output_file),
configuration=mock_configuration_with_invalid_archive_checksum,
)
assert output_file.read_text() == "Updated bad-app from 1.0.0 to 1.1.1\n"


def test_ops2deb_update_should_create_empty_summary_when_called_with_output_file_and_config_is_up_to_date( # noqa: E501
tmp_path, call_ops2deb
):
output_file = tmp_path / "summary.log"
call_ops2deb(
"update",
"--output-file",
str(output_file),
configuration=mock_configuration_up_to_date,
)
assert output_file.read_text() == ""


def test_ops2deb_update_should_succeed_with_single_blueprint_configuration(
tmp_path, call_ops2deb
):
Expand Down

0 comments on commit 8048240

Please sign in to comment.