diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-21 05:18:15 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-21 05:34:56 +0000 |
| commit | 7a81643367515a9d01eb2d4deb623e9a7c071a12 (patch) | |
| tree | 88d6f2e69ca051d2c94269f4753e2ef807882438 /tests/repository_creation.rs | |
| parent | 7dda553918705277c7fa5b903c6a40e4b4a0aa8d (diff) | |
add repository creation
Diffstat (limited to 'tests/repository_creation.rs')
| -rw-r--r-- | tests/repository_creation.rs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/repository_creation.rs b/tests/repository_creation.rs new file mode 100644 index 0000000..f57899d --- /dev/null +++ b/tests/repository_creation.rs | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | //! Repository Creation Integration Tests | ||
| 2 | //! | ||
| 3 | //! Tests that verify bare Git repositories are created when repository announcements | ||
| 4 | //! are accepted by ngit-grasp relay. | ||
| 5 | //! | ||
| 6 | //! # Test Strategy | ||
| 7 | //! | ||
| 8 | //! - Each test runs in complete isolation with its own fresh relay instance | ||
| 9 | //! - Uses macro to eliminate boilerplate while maintaining test isolation | ||
| 10 | //! - Calls individual test methods from grasp-audit for minimal duplication | ||
| 11 | //! - Automatic cleanup via TestRelay fixture (removes container and temp dirs) | ||
| 12 | //! | ||
| 13 | //! # Running Tests | ||
| 14 | //! | ||
| 15 | //! ```bash | ||
| 16 | //! # Run all repository creation tests | ||
| 17 | //! cargo test --test repository_creation | ||
| 18 | //! | ||
| 19 | //! # Run specific test | ||
| 20 | //! cargo test --test repository_creation test_bare_repo_created_on_announcement | ||
| 21 | //! | ||
| 22 | //! # With output | ||
| 23 | //! cargo test --test repository_creation -- --nocapture | ||
| 24 | //! ``` | ||
| 25 | |||
| 26 | mod common; | ||
| 27 | |||
| 28 | use common::TestRelay; | ||
| 29 | use grasp_audit::*; | ||
| 30 | use grasp_audit::specs::grasp01::RepositoryCreationTests; | ||
| 31 | |||
| 32 | /// Macro to generate isolated integration tests | ||
| 33 | /// | ||
| 34 | /// Each test runs with its own fresh relay instance to ensure complete isolation. | ||
| 35 | /// This eliminates issues with leftover repositories and ensures clean state. | ||
| 36 | macro_rules! isolated_test { | ||
| 37 | ($test_name:ident) => { | ||
| 38 | #[tokio::test] | ||
| 39 | async fn $test_name() { | ||
| 40 | let relay = TestRelay::start().await; | ||
| 41 | let config = AuditConfig::ci(); | ||
| 42 | let client = AuditClient::new(relay.url(), config) | ||
| 43 | .await | ||
| 44 | .expect("Failed to create audit client"); | ||
| 45 | |||
| 46 | let result = RepositoryCreationTests::$test_name(&client, relay.git_data_dir()).await; | ||
| 47 | |||
| 48 | relay.stop().await; | ||
| 49 | |||
| 50 | assert!( | ||
| 51 | result.passed, | ||
| 52 | "{} failed: {}", | ||
| 53 | stringify!($test_name), | ||
| 54 | result.error.as_deref().unwrap_or("unknown error") | ||
| 55 | ); | ||
| 56 | } | ||
| 57 | }; | ||
| 58 | } | ||
| 59 | |||
| 60 | // Generate isolated tests for all repository creation tests | ||
| 61 | isolated_test!(test_bare_repo_created_on_announcement); | ||
| 62 | isolated_test!(test_repo_creation_idempotent); | ||
| 63 | isolated_test!(test_bare_repo_structure); | ||
| 64 | isolated_test!(test_repo_cleanup); \ No newline at end of file | ||