From 97e21b62eab89bab1456db7df27df8f1c85399f0 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 21 Nov 2025 14:27:01 +0000 Subject: add http clone tests --- tests/git_clone.rs | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/git_clone.rs (limited to 'tests/git_clone.rs') 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 @@ +//! Git Clone Integration Tests +//! +//! Tests that verify Git clone operations work correctly through the HTTP backend. +//! +//! # Test Strategy +//! +//! - Each test runs in complete isolation with its own fresh relay instance +//! - Uses macro to eliminate boilerplate while maintaining test isolation +//! - Calls individual test methods from grasp-audit for minimal duplication +//! - Automatic cleanup via TestRelay fixture (removes container and temp dirs) +//! +//! # Running Tests +//! +//! ```bash +//! # Run all git clone tests +//! cargo test --test git_clone +//! +//! # Run specific test +//! cargo test --test git_clone test_basic_git_clone +//! +//! # With output +//! cargo test --test git_clone -- --nocapture +//! ``` + +mod common; + +use common::TestRelay; +use grasp_audit::specs::grasp01::GitCloneTests; +use grasp_audit::*; + +/// Macro to generate isolated integration tests with relay domain +/// +/// Each test runs with its own fresh relay instance to ensure complete isolation. +/// This eliminates issues with leftover repositories and ensures clean state. +macro_rules! isolated_test { + ($test_name:ident) => { + #[tokio::test] + async fn $test_name() { + let relay = TestRelay::start().await; + let config = AuditConfig::ci(); + let client = AuditClient::new(relay.url(), config) + .await + .expect("Failed to create audit client"); + + let result = GitCloneTests::$test_name( + &client, + relay.git_data_dir(), + &relay.domain(), + ) + .await; + + relay.stop().await; + + assert!( + result.passed, + "{} failed: {}", + stringify!($test_name), + result.error.as_deref().unwrap_or("unknown error") + ); + } + }; +} + +// Generate isolated tests for all git clone tests +isolated_test!(test_basic_git_clone); +isolated_test!(test_cloned_repo_structure); +isolated_test!(test_clone_url_format); \ No newline at end of file -- cgit v1.2.3