Skip to content

Commit 08dbdb6

Browse files
committed
add more tests
1 parent 9bbf636 commit 08dbdb6

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

tests/uv/lock/lock_run_test.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,33 @@ def _subprocess_env(self, workspace_dir: Path) -> dict[str, str]:
6363
env[key] = os.environ[key]
6464
return env
6565

66+
def test_requirements_run_script_for_new_file(self):
67+
"""Verify the requirements_new_file.run script has expected args."""
68+
run_script_path = _relative_rpath("requirements_new_file.run")
69+
content = run_script_path.read_text()
70+
71+
self.assertIn("#!/usr/bin/env bash", content)
72+
self.assertIn("BUILD_WORKSPACE_DIRECTORY", content)
73+
self.assertIn("--no-progress", content)
74+
self.assertIn("--quiet", content)
75+
self.assertIn("does_not_exist.txt", content)
76+
77+
def test_uv_lock_run_script(self):
78+
"""Verify the uv_lock_test.run script has expected args."""
79+
run_script_path = _relative_rpath("uv_lock_test.run")
80+
content = run_script_path.read_text()
81+
82+
self.assertIn("#!/usr/bin/env bash", content)
83+
self.assertIn("--no-progress", content)
84+
self.assertIn("--quiet", content)
85+
86+
def test_run_script_has_no_output_file_arg(self):
87+
"""Verify the uv lock .run script does NOT have --output-file (uv lock doesn't use it)."""
88+
run_script_path = _relative_rpath("uv_lock_test.run")
89+
content = run_script_path.read_text()
90+
91+
self.assertNotIn("--output-file", content)
92+
6693
def test_requirements_updating_for_the_first_time(self):
6794
# Given
6895
copier_path = _relative_rpath("requirements_new_file.update")
@@ -159,6 +186,24 @@ def test_requirements_run_on_the_first_time(self):
159186
output.stdout.decode("utf-8"),
160187
)
161188

189+
def test_requirements_run_script_has_expected_args(self):
190+
"""Verify the .run script template has expected args embedded."""
191+
run_script_path = _relative_rpath("requirements.run")
192+
content = run_script_path.read_text()
193+
194+
self.assertIn("#!/usr/bin/env bash", content)
195+
self.assertIn("BUILD_WORKSPACE_DIRECTORY", content)
196+
self.assertIn('"$@"', content)
197+
self.assertIn("--custom-compile-command", content)
198+
self.assertIn("--generate-hashes", content)
199+
self.assertIn("--no-strip-extras", content)
200+
self.assertIn("--no-python-downloads", content)
201+
self.assertIn("--no-cache", content)
202+
self.assertIn("--no-progress", content)
203+
self.assertIn("--quiet", content)
204+
self.assertIn("--output-file", content)
205+
self.assertIn("requirements.txt", content)
206+
162207
def test_requirements_run(self):
163208
# Given
164209
copier_path = _relative_rpath("requirements.run")

tests/uv/lock/lock_tests.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def lock_test_suite(name):
6666
"requirements.update",
6767
"requirements.run",
6868
"testdata/requirements.txt",
69+
"uv_lock_test.run",
6970
],
7071
main = "lock_run_test.py",
7172
tags = [

0 commit comments

Comments
 (0)