From d9c9ef2ff92b687f5ff5585b08b2eead8f139a02 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 5 Nov 2025 11:48:35 +0000 Subject: feat(grasp-audit): improve test infrastructure and error handling - Fix compilation error in test setup (use .expect() instead of ?) - Add comprehensive error messages with troubleshooting guidance - Implement connection verification in AuditClient with retry logic - Update AGENTS.md with testing troubleshooting section - Verify all changes: 4/18 tests passing as expected Error messages now include: - Specific context about failures (event IDs, repo IDs, URLs) - Example commands for resolution (docker, nak verification) - References to helper scripts (test-ngit-relay.sh) Tests compile cleanly and run successfully against ngit-relay. --- grasp-audit/src/client.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'grasp-audit/src/client.rs') diff --git a/grasp-audit/src/client.rs b/grasp-audit/src/client.rs index 4831d3f..b80b59f 100644 --- a/grasp-audit/src/client.rs +++ b/grasp-audit/src/client.rs @@ -24,11 +24,12 @@ impl AuditClient { // Wait for connection to establish (with retries) let mut attempts = 0; + let mut connected = false; while attempts < 20 { tokio::time::sleep(Duration::from_millis(100)).await; let relays = client.relays().await; - let connected = relays.values().any(|r| r.is_connected()); + connected = relays.values().any(|r| r.is_connected()); if connected { break; @@ -37,6 +38,25 @@ impl AuditClient { attempts += 1; } + // Verify we actually connected + if !connected { + return Err(anyhow!( + "Failed to connect to relay at '{}'\n\ + \n\ + Possible causes:\n\ + • Relay is not running at this address\n\ + • Network connectivity issues\n\ + • Incorrect URL or port\n\ + \n\ + To start ngit-relay for testing:\n\ + docker run --rm -p 18081:8081 ghcr.io/danconwaydev/ngit-relay:latest\n\ + \n\ + Or use the test script:\n\ + cd grasp-audit && ./test-ngit-relay.sh", + relay_url + )); + } + // Give it a bit more time to stabilize tokio::time::sleep(Duration::from_millis(200)).await; -- cgit v1.2.3