migrate clan history to clan-vm-manager

this functionality is not really useful or used in clan-vm-manager and
therefore should live in the clan-vm-manager.

Not porting the test for now because we probably get rid of the clan-vm-manager soon in favour of the UI.
This commit is contained in:
Jörg Thalheim
2025-04-16 14:22:45 +02:00
parent 42025fbfff
commit d2173cb120
13 changed files with 79 additions and 111 deletions

View File

@@ -1,47 +0,0 @@
import json
from typing import TYPE_CHECKING
import pytest
from clan_cli.dirs import user_history_file
from clan_cli.history.add import HistoryEntry
from clan_cli.tests.fixtures_flakes import FlakeForTest
from clan_cli.tests.helpers import cli
from clan_cli.tests.stdout import CaptureOutput
if TYPE_CHECKING:
pass
@pytest.mark.impure
def test_history_add(
test_flake_with_core: FlakeForTest,
) -> None:
cmd = [
"history",
"add",
f"clan://{test_flake_with_core.path}#vm1",
]
cli.run(cmd)
history_file = user_history_file()
assert history_file.exists()
history = [
HistoryEntry.from_json(entry) for entry in json.loads(history_file.read_text())
]
assert str(history[0].flake.flake_url) == str(test_flake_with_core.path)
@pytest.mark.impure
def test_history_list(
capture_output: CaptureOutput,
test_flake_with_core: FlakeForTest,
) -> None:
with capture_output as output:
cli.run(["history", "list"])
assert str(test_flake_with_core.path) not in output.out
cli.run(["history", "add", f"clan://{test_flake_with_core.path}#vm1"])
with capture_output as output:
cli.run(["history", "list"])
assert str(test_flake_with_core.path) in output.out