|
131 | 131 | print(output) |
132 | 132 | raise Exception(f"{error_msg}: expected {expected}, got {actual}") |
133 | 133 |
|
| 134 | + def verify_packages_in_store(machine, pkg_paths, should_exist=True): |
| 135 | + """ |
| 136 | + Verify whether packages exist in the store. |
| 137 | +
|
| 138 | + Args: |
| 139 | + machine: The machine to check on |
| 140 | + pkg_paths: List of package paths to check (or single path) |
| 141 | + should_exist: If True, verify packages exist; if False, verify they don't |
| 142 | + """ |
| 143 | + paths = [pkg_paths] if isinstance(pkg_paths, str) else pkg_paths |
| 144 | + for pkg in paths: |
| 145 | + if should_exist: |
| 146 | + machine.succeed(f"nix path-info {pkg}") |
| 147 | + else: |
| 148 | + machine.fail(f"nix path-info {pkg}") |
| 149 | +
|
134 | 150 | def setup_s3(populate_bucket=[], public=False): |
135 | 151 | """ |
136 | 152 | Decorator that creates/destroys a unique bucket for each test. |
|
321 | 337 | print(f" ✓ Store URL: {store_info['url']}") |
322 | 338 |
|
323 | 339 | # Test copy from store |
324 | | - client.fail(f"nix path-info {PKGS['A']}") |
| 340 | + verify_packages_in_store(client, PKGS['A'], should_exist=False) |
325 | 341 |
|
326 | 342 | output = client.succeed( |
327 | 343 | f"{ENV_WITH_CREDS} nix copy --debug --no-check-sigs " |
|
335 | 351 | "Client credential provider caching failed" |
336 | 352 | ) |
337 | 353 |
|
338 | | - client.succeed(f"nix path-info {PKGS['A']}") |
| 354 | + verify_packages_in_store(client, [PKGS['A'], PKGS['B'], PKGS['C']]) |
339 | 355 |
|
340 | 356 | print(" ✓ nix copy works") |
341 | 357 | print(" ✓ Credentials cached on client") |
|
361 | 377 | print(f" ✓ Store URL: {store_info['url']}") |
362 | 378 |
|
363 | 379 | # Verify packages are not yet in client store |
364 | | - client.fail(f"nix path-info {PKGS['A']}") |
365 | | - client.fail(f"nix path-info {PKGS['B']}") |
| 380 | + verify_packages_in_store(client, [PKGS['A'], PKGS['B']], should_exist=False) |
366 | 381 |
|
367 | 382 | # Test copy from public bucket without credentials |
368 | 383 | client.succeed( |
|
371 | 386 | ) |
372 | 387 |
|
373 | 388 | # Verify packages were copied successfully |
374 | | - client.succeed(f"nix path-info {PKGS['A']}") |
375 | | - client.succeed(f"nix path-info {PKGS['B']}") |
| 389 | + verify_packages_in_store(client, [PKGS['A'], PKGS['B']]) |
376 | 390 |
|
377 | 391 | print(" ✓ nix copy from public bucket works without credentials") |
378 | 392 |
|
|
475 | 489 |
|
476 | 490 | # Verify client can download and decompress |
477 | 491 | client.succeed(f"{ENV_WITH_CREDS} nix copy --from '{store_url}' --no-check-sigs {PKGS['B']}") |
478 | | - client.succeed(f"nix path-info {PKGS['B']}") |
| 492 | + verify_packages_in_store(client, PKGS['B']) |
479 | 493 |
|
480 | 494 | print(" ✓ Client decompressed .narinfo successfully") |
481 | 495 |
|
|
503 | 517 |
|
504 | 518 | # Verify client can download with mixed compression |
505 | 519 | client.succeed(f"{ENV_WITH_CREDS} nix copy --from '{store_url}' --no-check-sigs {PKGS['C']}") |
506 | | - client.succeed(f"nix path-info {PKGS['C']}") |
| 520 | + verify_packages_in_store(client, PKGS['C']) |
507 | 521 |
|
508 | 522 | print(" ✓ Client downloaded package with mixed compression") |
509 | 523 |
|
|
0 commit comments