Skip to content

Commit c30f7f5

Browse files
committed
fix: prelaunch test fixes
CAS on local and S3 refs treats expected_commit_id=None as no constraint; CLI status requires an existing repository; the s3 dataset-roots test isolates its worktree.
1 parent c51bbc8 commit c30f7f5

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

src/fluxel/core/objects/local.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,11 @@ def compare_and_set_branch_ref(
130130
current_token = self.version_token("ref", branch)
131131
if current_token != expected_version_token:
132132
return False
133-
current_state = self.read_branch_ref(branch)
134-
current_commit_id = current_state.commit_id if current_state else None
135-
if current_commit_id != expected_commit_id:
136-
return False
133+
if expected_commit_id is not None:
134+
current_state = self.read_branch_ref(branch)
135+
current_commit_id = current_state.commit_id if current_state else None
136+
if current_commit_id != expected_commit_id:
137+
return False
137138
self.write_branch_ref(branch, commit_id)
138139
return True
139140

src/fluxel/core/objects/s3.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ def compare_and_set_branch_ref(
225225
current_version = current.version_token if current else None
226226
if current_version != expected_version_token:
227227
return False
228-
current_commit_id = current.commit_id if current else None
229-
if current_commit_id != expected_commit_id:
230-
return False
228+
if expected_commit_id is not None:
229+
current_commit_id = current.commit_id if current else None
230+
if current_commit_id != expected_commit_id:
231+
return False
231232

232233
try:
233234
if expected_version_token is None:

src/fluxel/core/repository.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,9 @@ def move_staged(
851851
def status(
852852
root: str | Path, *, ref: str | None = None, working_tree: bool = True
853853
) -> StageStatus:
854-
return open_repository(root).status(ref=ref, working_tree=working_tree)
854+
return open_repository(root, must_exist=True).status(
855+
ref=ref, working_tree=working_tree
856+
)
855857

856858

857859
def diff(root: str | Path, from_ref: str, to_ref: str) -> list[DiffEntry]:

tests/test_prelaunch_fixes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ def test_s3_atomic_cas_conditional_write(fake_s3_installer) -> None:
6262
assert updated_state.commit_id == "2" * 64
6363

6464

65-
def test_vfs_s3_dataset_roots(fake_s3_installer, tmp_path: Path) -> None:
65+
def test_vfs_s3_dataset_roots(
66+
fake_s3_installer, tmp_path: Path, monkeypatch
67+
) -> None:
6668
client = fake_s3_installer({})
6769
repo_uri = "s3://demo-bucket/repos/remote_demo"
70+
monkeypatch.chdir(tmp_path)
6871

6972
(tmp_path / "data.txt").write_text("s3 dataset content")
7073
assert run_cli(["commit", "--repo", repo_uri, "-m", "remote seed"]) == 0

0 commit comments

Comments
 (0)