diff --git a/tests/test_tier2_setup_bootstrap.py b/tests/test_tier2_setup_bootstrap.py new file mode 100644 index 00000000..e30b78dc --- /dev/null +++ b/tests/test_tier2_setup_bootstrap.py @@ -0,0 +1,39 @@ +"""Opt-in integration test for the setup_tier2_clone.ps1 bootstrap. + +Runs the script in -WhatIf mode against a fixture workspace. The full +non-WhatIf run is a manual verification (the user runs it once and +inspects the result). +""" +import os +import subprocess +from pathlib import Path + +import pytest + +pytestmark = [ + pytest.mark.skipif( + not os.environ.get("TIER2_SANDBOX_TESTS"), + reason="opt-in: bootstrap test off by default; set TIER2_SANDBOX_TESTS=1", + ), + pytest.mark.tier2_sandbox, +] + + +def test_bootstrap_whatif_does_not_create_clone(tmp_path: Path) -> None: + """pwsh -WhatIf should print the steps but not actually clone.""" + fake_main = tmp_path / "fake_main" + fake_main.mkdir() + fake_clone = tmp_path / "fake_clone" + script = Path("scripts/tier2/setup_tier2_clone.ps1").resolve() + result = subprocess.run( + [ + "pwsh", "-NoProfile", "-File", str(script), + "-MainRepoPath", str(fake_main), + "-Tier2ClonePath", str(fake_clone), + "-WhatIf", + ], + capture_output=True, text=True, timeout=60, + ) + assert result.returncode == 0, f"pwsh exit {result.returncode}\nstdout={result.stdout}\nstderr={result.stderr}" + assert "What if" in result.stdout or "starting bootstrap" in result.stdout or "Bootstrap Tier 2 clone" in result.stdout + assert not fake_clone.exists(), "-WhatIf should not have created the clone"