mirror of
https://relay.ngit.dev/npub15qydau2hjma6ngxkl2cyar74wzyjshvl65za5k5rl69264ar2exs5cyejr/ngit-grasp.git
synced 2026-10-05 15:08:24 +00:00
Route new announcements to purgatory instead of accepting immediately. Announcements are promoted to the database when git data arrives, ensuring we only serve announcements for repos with actual content. Implemented: - AnnouncementPurgatoryEntry type and DashMap store - Route new announcements to purgatory (replacement announcements skip) - Promote announcements on git data arrival (process_purgatory_announcements) - Authorization checks purgatory announcements (fetch_repository_data_with_purgatory) - State policy uses purgatory announcements for maintainer validation - Cleanup task handles announcement expiry - Updated count()/cleanup() to 3-tuples Known broken: - test_archive_read_only_creates_bare_repo fails: sync module does not treat purgatory announcements as confirmed repos, so per-repo sync (state events, PRs) is never triggered for purgatory announcements - Announcement persistence (save/restore) not implemented - SyncLevel (StateOnly vs Full) not implemented - Soft expiry two-phase not implemented - Expiry extension on state event / git auth not wired up
83 lines
2.9 KiB
Rust
83 lines
2.9 KiB
Rust
//! Purgatory Integration Tests
|
|
//!
|
|
//! Tests ngit-grasp relay's implementation of GRASP-01 purgatory behavior.
|
|
//! Uses grasp-audit library to avoid code duplication.
|
|
//!
|
|
//! # 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 purgatory tests
|
|
//! cargo test --test purgatory
|
|
//!
|
|
//! # Run specific test
|
|
//! cargo test --test purgatory test_state_event_not_served_before_git_data
|
|
//!
|
|
//! # With output
|
|
//! cargo test --test purgatory -- --nocapture
|
|
//! ```
|
|
|
|
mod common;
|
|
|
|
use common::TestRelay;
|
|
use grasp_audit::specs::grasp01::PurgatoryTests;
|
|
use grasp_audit::{AuditClient, AuditConfig};
|
|
|
|
/// Macro to generate isolated integration tests for purgatory
|
|
///
|
|
/// 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_purgatory_test {
|
|
($test_name:ident) => {
|
|
#[tokio::test]
|
|
async fn $test_name() {
|
|
let relay = TestRelay::start().await;
|
|
let config = AuditConfig::isolated();
|
|
let client = AuditClient::new(relay.url(), config)
|
|
.await
|
|
.expect("Failed to create audit client");
|
|
|
|
let result = PurgatoryTests::$test_name(&client).await;
|
|
|
|
relay.stop().await;
|
|
|
|
assert!(
|
|
result.passed,
|
|
"{} failed: {}",
|
|
stringify!($test_name),
|
|
result.error.as_deref().unwrap_or("unknown error")
|
|
);
|
|
}
|
|
};
|
|
}
|
|
|
|
// ============================================================
|
|
// Announcement Purgatory Tests
|
|
// ============================================================
|
|
|
|
isolated_purgatory_test!(test_announcement_not_served_before_git_data);
|
|
isolated_purgatory_test!(test_announcement_served_after_git_push);
|
|
isolated_purgatory_test!(test_bare_repo_exists_for_purgatory_announcement);
|
|
isolated_purgatory_test!(test_state_event_accepted_for_purgatory_announcement);
|
|
|
|
// ============================================================
|
|
// State Event Purgatory Tests (already implemented)
|
|
// ============================================================
|
|
|
|
isolated_purgatory_test!(test_state_event_not_served_before_git_data);
|
|
isolated_purgatory_test!(test_state_event_served_after_git_push);
|
|
|
|
// ============================================================
|
|
// PR Purgatory Tests
|
|
// ============================================================
|
|
|
|
isolated_purgatory_test!(test_pr_event_accepted_into_purgatory_and_isnt_served);
|
|
isolated_purgatory_test!(test_pr_event_in_purgatory_git_push_accepted);
|
|
isolated_purgatory_test!(test_pr_event_served_after_git_push);
|