upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/client.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-02 21:20:17 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-02 21:20:17 +0000
commit72683beea066d066637e747c40dc859fb709babf (patch)
tree2db3462ebbcb7501e56491148cc3ffa7aa294071 /grasp-audit/src/client.rs
parent5c10ca008413744b09136618eaa85275c997704c (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/client.rs')
-rw-r--r--grasp-audit/src/client.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/grasp-audit/src/client.rs b/grasp-audit/src/client.rs
index e4e9f07..21c70be 100644
--- a/grasp-audit/src/client.rs
+++ b/grasp-audit/src/client.rs
@@ -199,7 +199,7 @@ impl AuditClient {
199 /// ```no_run 199 /// ```no_run
200 /// # use grasp_audit::*; 200 /// # use grasp_audit::*;
201 /// # async fn example() -> anyhow::Result<()> { 201 /// # async fn example() -> anyhow::Result<()> {
202 /// let config = AuditConfig::ci(); 202 /// let config = AuditConfig::shared();
203 /// let client = AuditClient::new("ws://localhost:7000", config).await?; 203 /// let client = AuditClient::new("ws://localhost:7000", config).await?;
204 /// 204 ///
205 /// // Create event with automatic audit tags 205 /// // Create event with automatic audit tags
@@ -221,8 +221,8 @@ impl AuditClient {
221 pub async fn query(&self, mut filter: Filter) -> Result<Vec<Event>> { 221 pub async fn query(&self, mut filter: Filter) -> Result<Vec<Event>> {
222 use nostr_sdk::prelude::{Alphabet, SingleLetterTag}; 222 use nostr_sdk::prelude::{Alphabet, SingleLetterTag};
223 223
224 if self.config.mode == AuditMode::CI { 224 if self.config.mode == AuditMode::Isolated {
225 // In CI mode, only see our own audit events 225 // In Isolated mode, only see our own audit events
226 // Filter by "t" tags (hashtags) 226 // Filter by "t" tags (hashtags)
227 let t_tag = SingleLetterTag::lowercase(Alphabet::T); 227 let t_tag = SingleLetterTag::lowercase(Alphabet::T);
228 filter = filter 228 filter = filter
@@ -505,7 +505,7 @@ mod tests {
505 505
506 #[tokio::test] 506 #[tokio::test]
507 async fn test_client_creation() { 507 async fn test_client_creation() {
508 let config = AuditConfig::ci(); 508 let config = AuditConfig::isolated();
509 509
510 // This will fail if no relay is running, which is expected in tests 510 // This will fail if no relay is running, which is expected in tests
511 // In real usage, there should be a relay at the URL 511 // In real usage, there should be a relay at the URL
@@ -514,13 +514,13 @@ mod tests {
514 // We can't test connection without a running relay 514 // We can't test connection without a running relay
515 // But we can test that the client is created 515 // But we can test that the client is created
516 if let Ok(client) = result { 516 if let Ok(client) = result {
517 assert_eq!(client.config.mode, AuditMode::CI); 517 assert_eq!(client.config.mode, AuditMode::Isolated);
518 } 518 }
519 } 519 }
520 520
521 #[test] 521 #[test]
522 fn test_event_builder() { 522 fn test_event_builder() {
523 let config = AuditConfig::ci(); 523 let config = AuditConfig::isolated();
524 let keys = Keys::generate(); 524 let keys = Keys::generate();
525 let maintainer_keys = Keys::generate(); 525 let maintainer_keys = Keys::generate();
526 let recursive_maintainer_keys = Keys::generate(); 526 let recursive_maintainer_keys = Keys::generate();
@@ -543,7 +543,7 @@ mod tests {
543 543
544 #[test] 544 #[test]
545 fn test_audit_tags_automatically_added() { 545 fn test_audit_tags_automatically_added() {
546 let config = AuditConfig::ci(); 546 let config = AuditConfig::isolated();
547 let keys = Keys::generate(); 547 let keys = Keys::generate();
548 let maintainer_keys = Keys::generate(); 548 let maintainer_keys = Keys::generate();
549 let recursive_maintainer_keys = Keys::generate(); 549 let recursive_maintainer_keys = Keys::generate();
@@ -585,8 +585,8 @@ mod tests {
585 "Missing 'grasp-audit-test-event' tag" 585 "Missing 'grasp-audit-test-event' tag"
586 ); 586 );
587 assert!( 587 assert!(
588 tag_contents.iter().any(|t| t.starts_with("audit-ci-")), 588 tag_contents.iter().any(|t| t.starts_with("audit-isolated-")),
589 "Missing 'audit-ci-*' tag" 589 "Missing 'audit-isolated-*' tag"
590 ); 590 );
591 assert!( 591 assert!(
592 tag_contents 592 tag_contents
@@ -604,7 +604,7 @@ mod tests {
604 604
605 #[tokio::test] 605 #[tokio::test]
606 async fn test_create_repo_announcement_with_maintainers() { 606 async fn test_create_repo_announcement_with_maintainers() {
607 let config = AuditConfig::ci(); 607 let config = AuditConfig::isolated();
608 let client = AuditClient::new_test(config); 608 let client = AuditClient::new_test(config);
609 609
610 // Create test maintainer pubkeys (hex format) 610 // Create test maintainer pubkeys (hex format)