diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-02 21:20:17 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-12-02 21:20:17 +0000 |
| commit | 72683beea066d066637e747c40dc859fb709babf (patch) | |
| tree | 2db3462ebbcb7501e56491148cc3ffa7aa294071 /grasp-audit/src/bin/grasp-audit.rs | |
| parent | 5c10ca008413744b09136618eaa85275c997704c (diff) | |
refactor: rename AuditMode variants and change CLI default to shared
Breaking change: Renamed AuditMode enum variants for clarity:
- AuditMode::CI -> AuditMode::Isolated (fresh fixtures per test)
- AuditMode::Production -> AuditMode::Shared (reuse fixtures across tests)
Config constructors renamed (with deprecated aliases):
- AuditConfig::ci() -> AuditConfig::isolated()
- AuditConfig::production() -> AuditConfig::shared()
CLI default changed from 'ci' to 'shared' mode, which enables
fixture caching across tests. This fixes the issue where fixtures
were being re-created for every test in CLI mode.
Fixture caching behavior:
- Shared mode (CLI default): Uses client's cache, fixtures reused
- Isolated mode (for cargo test): Local cache per TestContext
Diffstat (limited to 'grasp-audit/src/bin/grasp-audit.rs')
| -rw-r--r-- | grasp-audit/src/bin/grasp-audit.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/grasp-audit/src/bin/grasp-audit.rs b/grasp-audit/src/bin/grasp-audit.rs index 48c1580..0d88bce 100644 --- a/grasp-audit/src/bin/grasp-audit.rs +++ b/grasp-audit/src/bin/grasp-audit.rs | |||
| @@ -20,8 +20,11 @@ enum Commands { | |||
| 20 | #[arg(short, long)] | 20 | #[arg(short, long)] |
| 21 | relay: String, | 21 | relay: String, |
| 22 | 22 | ||
| 23 | /// Mode: ci or production | 23 | /// Fixture mode: shared (default) or isolated |
| 24 | #[arg(short, long, default_value = "ci")] | 24 | /// |
| 25 | /// - shared: Fixtures are cached and reused across tests (efficient for sequential test runs) | ||
| 26 | /// - isolated: Each test creates fresh fixtures (for parallel tests like cargo test) | ||
| 27 | #[arg(short, long, default_value = "shared")] | ||
| 25 | mode: String, | 28 | mode: String, |
| 26 | 29 | ||
| 27 | /// Spec to test (nip01-smoke, nip11, event-acceptance, cors, git-clone, push-auth, repo-creation, all) | 30 | /// Spec to test (nip01-smoke, nip11, event-acceptance, cors, git-clone, push-auth, repo-creation, all) |
| @@ -53,10 +56,14 @@ async fn main() -> Result<()> { | |||
| 53 | spec, | 56 | spec, |
| 54 | git_data_dir, | 57 | git_data_dir, |
| 55 | } => { | 58 | } => { |
| 59 | #[allow(deprecated)] | ||
| 56 | let mut config = match mode.as_str() { | 60 | let mut config = match mode.as_str() { |
| 61 | "shared" => AuditConfig::shared(), | ||
| 62 | "isolated" => AuditConfig::isolated(), | ||
| 63 | // Backwards compatibility aliases | ||
| 57 | "ci" => AuditConfig::ci(), | 64 | "ci" => AuditConfig::ci(), |
| 58 | "production" => AuditConfig::production(), | 65 | "production" => AuditConfig::production(), |
| 59 | _ => return Err(anyhow!("Invalid mode: {}. Use 'ci' or 'production'", mode)), | 66 | _ => return Err(anyhow!("Invalid mode: {}. Use 'shared' or 'isolated'", mode)), |
| 60 | }; | 67 | }; |
| 61 | 68 | ||
| 62 | // Audit needs to create events to test the relay, so disable read-only mode | 69 | // Audit needs to create events to test the relay, so disable read-only mode |