From 5f759a7f90b1f9b53ddd922ebcb1e34cb96f84d7 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 13 Jan 2024 14:41:15 +1100 Subject: [PATCH] additional tests for existing get_pants.sh functionality --- tests/test_get_pants.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_get_pants.py b/tests/test_get_pants.py index d4331aa..559d4ab 100755 --- a/tests/test_get_pants.py +++ b/tests/test_get_pants.py @@ -39,3 +39,27 @@ def test_installs_pants_when_no_args(tmp_path: Path) -> None: assert b"Installed the pants launcher from" in proc.stderr _check_launcher_runs(tmp_path / ".local" / "bin" / "pants") + + +def test_installs_specific_version_when_version_arg(tmp_path: Path) -> None: + _run(home=tmp_path, args=["--version", "0.10.0"]) + _check_launcher_runs(tmp_path / ".local" / "bin" / "pants", expected_version="0.10.0") + + +def test_fails_with_error_when_incorrect_version_arg(tmp_path: Path) -> None: + # we've moved past 0.1.x and never did quite this many patch releases. + proc = _run(home=tmp_path, args=["--version", "0.1.99999"], check=False) + assert proc.returncode != 0 + assert proc.stdout == b"" + assert b"The requested URL returned error: 404" in proc.stderr + + +def test_installs_to_specific_dir_when_bin_dir_arg(tmp_path: Path) -> None: + custom = tmp_path / "custom" + _run(home=tmp_path, args=["--bin-dir", str(custom)]) + _check_launcher_runs(custom / "pants") + + +def test_installs_with_base_name_when_base_name_arg(tmp_path: Path) -> None: + _run(home=tmp_path, args=["--base-name", "other-name"]) + _check_launcher_runs(tmp_path / ".local" / "bin" / "other-name")