Warn on an untested cv4pve-cli version at startup
At startup the app runs `cv4pve-cli --version`. If it differs from cli.TESTED_VERSION (2.4.0), a warning says which version was found and which one was tested. The app parses output formats that are not a stable API: the config list text, prune-backups as a JSON string, the CT ip-addresses JSON string and the exit codes with --wait. A newer cv4pve-cli could break them in confusing ways. If cv4pve-cli cannot be run at all, an error says so once, instead of every later call failing without explanation. The README notes the tested version. Closes #14 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #27.
This commit is contained in:
1 parent
364f8e2137
commit
e7569a7bf7
5 files changed
+83
-1
No files matched your search
@@ -50,6 +50,7 @@ class Fake:
|
||||
self.use_error = None
|
||||
self.use_hook = None
|
||||
self.guests_by_context = {}
|
||||
self.cli_version, self.version_error = "2.4.0", None
|
||||
self.unprotected, self.unprotected_error = set(), None
|
||||
self.list_hook = None
|
||||
# delivery A (guest info screen)
|
||||
@@ -143,6 +144,11 @@ class Fake:
|
||||
raise self.unprotected_error
|
||||
return set(self.unprotected)
|
||||
|
||||
def version(self):
|
||||
if self.version_error:
|
||||
raise self.version_error
|
||||
return self.cli_version
|
||||
|
||||
def contexts(self):
|
||||
self.contexts_calls += 1
|
||||
if self.contexts_error:
|
||||
@@ -307,6 +313,7 @@ def fake(monkeypatch):
|
||||
"bridges",
|
||||
"set_net",
|
||||
"not_backed_up",
|
||||
"version",
|
||||
"snapshots",
|
||||
"take_snapshot",
|
||||
"rollback_snapshot",
|
||||
@@ -3471,3 +3478,36 @@ async def test_frame_subtitle_singular_for_one_package_update(fake):
|
||||
async with app.run_test(size=SIZE) as pilot:
|
||||
await settle(app, pilot)
|
||||
assert frame_subtitle(app).endswith("· 1 package update")
|
||||
|
||||
|
||||
# --- #14: warn on an untested cv4pve-cli version -------------------------------------
|
||||
|
||||
|
||||
async def test_no_warning_for_the_tested_cli_version(fake):
|
||||
app = make_app()
|
||||
async with app.run_test(size=SIZE) as pilot:
|
||||
await settle(app, pilot)
|
||||
assert not any("tested with" in m for m, _ in app.seen)
|
||||
|
||||
|
||||
async def test_other_cli_version_warns_once(fake):
|
||||
fake.cli_version = "2.5.0"
|
||||
app = make_app()
|
||||
async with app.run_test(size=SIZE) as pilot:
|
||||
await settle(app, pilot)
|
||||
warned = [m for m, sev in app.seen if sev == "warning" and "tested with" in m]
|
||||
assert (
|
||||
len(warned) == 1
|
||||
and "2.5.0" in warned[0]
|
||||
and cli.TESTED_VERSION in warned[0]
|
||||
)
|
||||
|
||||
|
||||
async def test_cli_not_runnable_is_an_error_not_a_crash(fake):
|
||||
fake.version_error = cli.CliError(
|
||||
"[Errno 2] No such file or directory: 'cv4pve-cli'"
|
||||
)
|
||||
app = make_app()
|
||||
async with app.run_test(size=SIZE) as pilot:
|
||||
await settle(app, pilot)
|
||||
assert any("cv4pve-cli" in m for m in errors(app)) and app.is_running
|
||||
Reference in new issue
Block a user