diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-21 14:27:01 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-21 14:27:01 +0000 |
| commit | 97e21b62eab89bab1456db7df27df8f1c85399f0 (patch) | |
| tree | d1315263d92a08ebe995823dab7794992c7522a5 /tests/git_clone.rs | |
| parent | 7d4bbb3f4954be163c28a42736852bb26e7abc4b (diff) | |
add http clone tests
Diffstat (limited to 'tests/git_clone.rs')
| -rw-r--r-- | tests/git_clone.rs | 67 |
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 | |||
| 25 | mod common; | ||
| 26 | |||
| 27 | use common::TestRelay; | ||
| 28 | use grasp_audit::specs::grasp01::GitCloneTests; | ||
| 29 | use 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. | ||
| 35 | macro_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 | ||
| 65 | isolated_test!(test_basic_git_clone); | ||
| 66 | isolated_test!(test_cloned_repo_structure); | ||
| 67 | isolated_test!(test_clone_url_format); \ No newline at end of file | ||