clan create: fix failure when path was single word
This should better be fixed with types. It should be possible to initialize a flake from a Path, making it very clear that a path `foo` is meant and not a remote flake called `foo`
This commit is contained in:
@@ -84,7 +84,7 @@ def create_clan(opts: CreateOptions) -> None:
|
|||||||
# _postprocess_flake_hook must be private to avoid leaking it to the public API
|
# _postprocess_flake_hook must be private to avoid leaking it to the public API
|
||||||
post_process=opts._postprocess_flake_hook, # noqa: SLF001
|
post_process=opts._postprocess_flake_hook, # noqa: SLF001
|
||||||
) as _clan_dir:
|
) as _clan_dir:
|
||||||
flake = Flake(str(opts.dest))
|
flake = Flake(str(Path(opts.dest).absolute()))
|
||||||
|
|
||||||
if opts.setup_git:
|
if opts.setup_git:
|
||||||
run(git_command(dest, "init"))
|
run(git_command(dest, "init"))
|
||||||
|
|||||||
@@ -38,6 +38,29 @@ def test_create_simple(tmp_path: Path, offline_flake_hook: Any) -> None:
|
|||||||
assert "instances" in inventory
|
assert "instances" in inventory
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.with_core
|
||||||
|
def test_can_handle_path_without_slash(
|
||||||
|
tmp_path: Path,
|
||||||
|
offline_flake_hook: Any,
|
||||||
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
|
) -> None:
|
||||||
|
"""
|
||||||
|
Tests for a regression, where it broke when the path is a single word like `foo`.
|
||||||
|
The flake identifier was interpreted as an external flake.
|
||||||
|
"""
|
||||||
|
monkeypatch.chdir(tmp_path)
|
||||||
|
dest = Path("test_clan")
|
||||||
|
|
||||||
|
opts = CreateOptions(
|
||||||
|
dest=dest, template="default", _postprocess_flake_hook=offline_flake_hook
|
||||||
|
)
|
||||||
|
|
||||||
|
create_clan(opts)
|
||||||
|
|
||||||
|
assert dest.exists()
|
||||||
|
assert dest.is_dir()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.with_core
|
@pytest.mark.with_core
|
||||||
def test_create_with_name(tmp_path: Path, offline_flake_hook: Any) -> None:
|
def test_create_with_name(tmp_path: Path, offline_flake_hook: Any) -> None:
|
||||||
"""
|
"""
|
||||||
Reference in New Issue
Block a user