"""Tests for clone target-path derivation (mgf.vm.core.operations.clone_paths)."""

from __future__ import annotations

from pathlib import Path

from mgf.vm.core.operations.clone_paths import derive_clone_path


def test_primary_disk_is_unsuffixed() -> None:
    out = derive_clone_path(Path("/var/lib/vms/src.qcow2"), "clone", index=0)
    assert out == Path("/var/lib/vms/clone.qcow2")


def test_additional_disk_gets_index_suffix() -> None:
    out = derive_clone_path(Path("/var/lib/vms/src.qcow2"), "clone", index=2)
    assert out == Path("/var/lib/vms/clone-2.qcow2")


def test_keeps_source_suffix() -> None:
    out = derive_clone_path(Path("/disks/base.raw"), "c", index=0)
    assert out == Path("/disks/c.raw")


def test_defaults_suffix_to_qcow2_when_source_has_none() -> None:
    out = derive_clone_path(Path("/disks/base"), "c", index=0)
    assert out == Path("/disks/c.qcow2")


def test_stays_in_source_parent_directory() -> None:
    out = derive_clone_path(Path("/a/b/c/disk.qcow2"), "new", index=1)
    assert out.parent == Path("/a/b/c")
