upleb.uk

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

summaryrefslogtreecommitdiff
path: root/tests/git_clone.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/git_clone.rs')
-rw-r--r--tests/git_clone.rs67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/git_clone.rs b/tests/git_clone.rs
new file mode 100644
index 0000000..db82bea
--- /dev/null
+++ b/tests/git_clone.rs
@@ -0,0 +1,67 @@
1//! Git Clone Integration Tests
2//!
3//! Tests that verify Git clone operations work correctly through the HTTP backend.
4//!
5//! # Test Strategy
6//!
7//! - Each test runs in complete isolation with its own fresh relay instance
8//! - Uses macro to eliminate boilerplate while maintaining test isolation
9//! - Calls individual test methods from grasp-audit for minimal duplication
10//! - Automatic cleanup via TestRelay fixture (removes container and temp dirs)
11//!
12//! # Running Tests
13//!
14//! ```bash
15//! # Run all git clone tests
16//! cargo test --test git_clone
17//!
18//! # Run specific test
19//! cargo test --test git_clone test_basic_git_clone
20//!
21//! # With output
22//! cargo test --test git_clone -- --nocapture
23//! ```
24
25mod common;
26
27use common::TestRelay;
28use grasp_audit::specs::grasp01::GitCloneTests;
29use grasp_audit::*;
30
31/// Macro to generate isolated integration tests with relay domain
32///
33/// Each test runs with its own fresh relay instance to ensure complete isolation.
34/// This eliminates issues with leftover repositories and ensures clean state.
35macro_rules! isolated_test {
36 ($test_name:ident) => {
37 #[tokio::test]
38 async fn $test_name() {
39 let relay = TestRelay::start().await;
40 let config = AuditConfig::ci();
41 let client = AuditClient::new(relay.url(), config)
42 .await
43 .expect("Failed to create audit client");
44
45 let result = GitCloneTests::$test_name(
46 &client,
47 relay.git_data_dir(),
48 &relay.domain(),
49 )
50 .await;
51
52 relay.stop().await;
53
54 assert!(
55 result.passed,
56 "{} failed: {}",
57 stringify!($test_name),
58 result.error.as_deref().unwrap_or("unknown error")
59 );
60 }
61 };
62}
63
64// Generate isolated tests for all git clone tests
65isolated_test!(test_basic_git_clone);
66isolated_test!(test_cloned_repo_structure);
67isolated_test!(test_clone_url_format); \ No newline at end of file