2023-07-28 10:12:37 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2023-10-14 12:57:36 +00:00
|
|
|
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):
|
2023-10-14 12:57:36 +00:00
|
|
|
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()
|
2023-10-14 12:57:36 +00:00
|
|
|
assert _get_clan_flake_toplevel() == subdir
|