|
8 | 8 |
|
9 | 9 | from basic_memory.cli.commands.cloud.rclone_commands import ( |
10 | 10 | MIN_RCLONE_VERSION_EMPTY_DIRS, |
| 11 | + TIGRIS_CONSISTENCY_HEADERS, |
11 | 12 | RcloneError, |
12 | 13 | SyncProject, |
13 | 14 | bisync_initialized, |
@@ -40,6 +41,18 @@ def __call__(self, cmd: list[str], **kwargs): |
40 | 41 | return _RunResult(returncode=self._returncode, stdout=self._stdout) |
41 | 42 |
|
42 | 43 |
|
| 44 | +def _assert_has_consistency_headers(cmd: list[str]) -> None: |
| 45 | + """Assert the rclone command includes Tigris consistency headers.""" |
| 46 | + assert "--header-download" in cmd |
| 47 | + assert "X-Tigris-Consistent: true" in cmd |
| 48 | + assert "--header-upload" in cmd |
| 49 | + # Verify upload header value follows --header-upload |
| 50 | + upload_idx = cmd.index("--header-upload") |
| 51 | + assert cmd[upload_idx + 1] == "X-Tigris-Consistent: true" |
| 52 | + download_idx = cmd.index("--header-download") |
| 53 | + assert cmd[download_idx + 1] == "X-Tigris-Consistent: true" |
| 54 | + |
| 55 | + |
43 | 56 | def _write_filter_file(tmp_path: Path) -> Path: |
44 | 57 | p = tmp_path / "filters.txt" |
45 | 58 | p.write_text("- .git/**\n", encoding="utf-8") |
@@ -127,6 +140,7 @@ def test_project_sync_success(tmp_path): |
127 | 140 | assert cmd[:2] == ["rclone", "sync"] |
128 | 141 | assert Path(cmd[2]) == Path("/tmp/research") |
129 | 142 | assert cmd[3] == "basic-memory-cloud:my-bucket/research" |
| 143 | + _assert_has_consistency_headers(cmd) |
130 | 144 | assert "--filter-from" in cmd |
131 | 145 | assert str(filter_path) in cmd |
132 | 146 | assert "--dry-run" in cmd |
@@ -208,6 +222,7 @@ def test_project_bisync_success(tmp_path): |
208 | 222 | assert result is True |
209 | 223 | cmd, _ = runner.calls[0] |
210 | 224 | assert cmd[:2] == ["rclone", "bisync"] |
| 225 | + _assert_has_consistency_headers(cmd) |
211 | 226 | assert "--resilient" in cmd |
212 | 227 | assert "--conflict-resolve=newer" in cmd |
213 | 228 | assert "--max-delete=25" in cmd |
@@ -369,6 +384,7 @@ def test_project_check_success(tmp_path): |
369 | 384 | assert result is True |
370 | 385 | cmd, kwargs = runner.calls[0] |
371 | 386 | assert cmd[:2] == ["rclone", "check"] |
| 387 | + _assert_has_consistency_headers(cmd) |
372 | 388 | assert kwargs["capture_output"] is True |
373 | 389 | assert kwargs["text"] is True |
374 | 390 |
|
@@ -407,6 +423,8 @@ def test_project_ls_success(): |
407 | 423 | project = SyncProject(name="research", path="app/data/research") |
408 | 424 | files = project_ls(project, "my-bucket", run=runner, is_installed=lambda: True) |
409 | 425 | assert files == ["file1.md", "file2.md", "subdir/file3.md"] |
| 426 | + cmd, _ = runner.calls[0] |
| 427 | + _assert_has_consistency_headers(cmd) |
410 | 428 |
|
411 | 429 |
|
412 | 430 | def test_project_ls_with_subpath(): |
|
0 commit comments