clan-core/pkgs/clan-cli/tests/test_flakes_cli.py
DavHau 64649ff7a9
All checks were successful
checks-impure / test (pull_request) Successful in 2m3s
checks / test (pull_request) Successful in 3m8s
api/flake/list_history: init
Add an api endpoint to list the history of clan flakes that have been interacted with

Also add `clan flake list`
2023-11-17 17:56:14 +07:00

46 lines
895 B
Python

from typing import TYPE_CHECKING
from cli import Cli
from fixtures_flakes import FlakeForTest
from pytest import CaptureFixture
from clan_cli.dirs import user_history_file
if TYPE_CHECKING:
pass
def test_flakes_add(
test_flake: FlakeForTest,
) -> None:
cli = Cli()
cmd = [
"flakes",
"add",
str(test_flake.path),
]
cli.run(cmd)
history_file = user_history_file()
assert history_file.exists()
assert open(history_file).read().strip() == str(test_flake.path)
def test_flakes_list(
capsys: CaptureFixture,
test_flake: FlakeForTest,
) -> None:
cli = Cli()
cmd = [
"flakes",
"list",
]
cli.run(cmd)
assert str(test_flake.path) not in capsys.readouterr().out
cli.run(["flakes", "add", str(test_flake.path)])
cli.run(cmd)
assert str(test_flake.path) in capsys.readouterr().out