clan-core/pkgs/clan-cli/tests/test_dirs.py

23 lines
618 B
Python
Raw Normal View History

2023-07-28 10:12:37 +00:00
from pathlib import Path
import pytest
from clan_cli.dirs import _get_clan_flake_toplevel
2023-07-28 10:12:37 +00:00
from clan_cli.errors import ClanError
def test_get_clan_flake_toplevel(
2023-10-23 20:31:12 +00:00
monkeypatch: pytest.MonkeyPatch, temporary_home: Path
2023-07-28 10:12:37 +00:00
) -> None:
2023-10-23 20:31:12 +00:00
monkeypatch.chdir(temporary_home)
2023-07-28 10:12:37 +00:00
with pytest.raises(ClanError):
print(_get_clan_flake_toplevel())
2023-10-23 20:31:12 +00:00
(temporary_home / ".git").touch()
assert _get_clan_flake_toplevel() == temporary_home
2023-07-28 10:35:41 +00:00
2023-10-23 20:31:12 +00:00
subdir = temporary_home / "subdir"
2023-07-28 10:35:41 +00:00
subdir.mkdir()
monkeypatch.chdir(subdir)
(subdir / ".clan-flake").touch()
assert _get_clan_flake_toplevel() == subdir