diff options
Diffstat (limited to 'tests/purgatory_persistence.rs')
| -rw-r--r-- | tests/purgatory_persistence.rs | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/tests/purgatory_persistence.rs b/tests/purgatory_persistence.rs index 05cb44b..655b0d9 100644 --- a/tests/purgatory_persistence.rs +++ b/tests/purgatory_persistence.rs | |||
| @@ -96,11 +96,13 @@ async fn test_full_purgatory_save_restore_cycle() { | |||
| 96 | state_event1.clone(), | 96 | state_event1.clone(), |
| 97 | "repo1".to_string(), | 97 | "repo1".to_string(), |
| 98 | keys1.public_key(), | 98 | keys1.public_key(), |
| 99 | false, | ||
| 99 | ); | 100 | ); |
| 100 | purgatory.add_state( | 101 | purgatory.add_state( |
| 101 | state_event2.clone(), | 102 | state_event2.clone(), |
| 102 | "repo2".to_string(), | 103 | "repo2".to_string(), |
| 103 | keys2.public_key(), | 104 | keys2.public_key(), |
| 105 | false, | ||
| 104 | ); | 106 | ); |
| 105 | 107 | ||
| 106 | // Add PR events to purgatory | 108 | // Add PR events to purgatory |
| @@ -108,11 +110,13 @@ async fn test_full_purgatory_save_restore_cycle() { | |||
| 108 | pr_event1.clone(), | 110 | pr_event1.clone(), |
| 109 | pr_event1.id.to_hex(), | 111 | pr_event1.id.to_hex(), |
| 110 | "commit-abc".to_string(), | 112 | "commit-abc".to_string(), |
| 113 | false, | ||
| 111 | ); | 114 | ); |
| 112 | purgatory.add_pr( | 115 | purgatory.add_pr( |
| 113 | pr_event2.clone(), | 116 | pr_event2.clone(), |
| 114 | pr_event2.id.to_hex(), | 117 | pr_event2.id.to_hex(), |
| 115 | "commit-def".to_string(), | 118 | "commit-def".to_string(), |
| 119 | false, | ||
| 116 | ); | 120 | ); |
| 117 | 121 | ||
| 118 | // Add a PR placeholder (git-data-first scenario) | 122 | // Add a PR placeholder (git-data-first scenario) |
| @@ -294,7 +298,12 @@ async fn test_purgatory_downtime_adjustment() { | |||
| 294 | 298 | ||
| 295 | let state_event = create_state_event_with_refs(&keys, "repo1", &[("main", "abc123")]).unwrap(); | 299 | let state_event = create_state_event_with_refs(&keys, "repo1", &[("main", "abc123")]).unwrap(); |
| 296 | 300 | ||
| 297 | purgatory.add_state(state_event.clone(), "repo1".to_string(), keys.public_key()); | 301 | purgatory.add_state( |
| 302 | state_event.clone(), | ||
| 303 | "repo1".to_string(), | ||
| 304 | keys.public_key(), | ||
| 305 | false, | ||
| 306 | ); | ||
| 298 | 307 | ||
| 299 | // Save to disk | 308 | // Save to disk |
| 300 | purgatory.save_to_disk(&state_path).unwrap(); | 309 | purgatory.save_to_disk(&state_path).unwrap(); |
| @@ -372,7 +381,7 @@ async fn test_purgatory_file_cleanup_after_restore() { | |||
| 372 | 381 | ||
| 373 | let state_event = create_state_event_with_refs(&keys, "repo1", &[("main", "abc123")]).unwrap(); | 382 | let state_event = create_state_event_with_refs(&keys, "repo1", &[("main", "abc123")]).unwrap(); |
| 374 | 383 | ||
| 375 | purgatory.add_state(state_event, "repo1".to_string(), keys.public_key()); | 384 | purgatory.add_state(state_event, "repo1".to_string(), keys.public_key(), false); |
| 376 | 385 | ||
| 377 | // Save to disk | 386 | // Save to disk |
| 378 | purgatory.save_to_disk(&state_path).unwrap(); | 387 | purgatory.save_to_disk(&state_path).unwrap(); |
| @@ -440,7 +449,7 @@ async fn test_purgatory_restore_missing_file() { | |||
| 440 | // Should be able to add events normally | 449 | // Should be able to add events normally |
| 441 | let keys = Keys::generate(); | 450 | let keys = Keys::generate(); |
| 442 | let event = create_test_event(&keys, "test").await; | 451 | let event = create_test_event(&keys, "test").await; |
| 443 | purgatory.add_state(event, "repo1".to_string(), keys.public_key()); | 452 | purgatory.add_state(event, "repo1".to_string(), keys.public_key(), false); |
| 444 | 453 | ||
| 445 | let (_, state_count, _) = purgatory.count(); | 454 | let (_, state_count, _) = purgatory.count(); |
| 446 | assert_eq!(state_count, 1); | 455 | assert_eq!(state_count, 1); |
| @@ -579,8 +588,18 @@ async fn test_purgatory_multiple_state_events_same_identifier() { | |||
| 579 | let event1 = create_state_event_with_refs(&keys1, "repo1", &[("main", "abc123")]).unwrap(); | 588 | let event1 = create_state_event_with_refs(&keys1, "repo1", &[("main", "abc123")]).unwrap(); |
| 580 | let event2 = create_state_event_with_refs(&keys2, "repo1", &[("main", "def456")]).unwrap(); | 589 | let event2 = create_state_event_with_refs(&keys2, "repo1", &[("main", "def456")]).unwrap(); |
| 581 | 590 | ||
| 582 | purgatory.add_state(event1.clone(), "repo1".to_string(), keys1.public_key()); | 591 | purgatory.add_state( |
| 583 | purgatory.add_state(event2.clone(), "repo1".to_string(), keys2.public_key()); | 592 | event1.clone(), |
| 593 | "repo1".to_string(), | ||
| 594 | keys1.public_key(), | ||
| 595 | false, | ||
| 596 | ); | ||
| 597 | purgatory.add_state( | ||
| 598 | event2.clone(), | ||
| 599 | "repo1".to_string(), | ||
| 600 | keys2.public_key(), | ||
| 601 | false, | ||
| 602 | ); | ||
| 584 | 603 | ||
| 585 | // Save and restore | 604 | // Save and restore |
| 586 | purgatory.save_to_disk(&state_path).unwrap(); | 605 | purgatory.save_to_disk(&state_path).unwrap(); |
| @@ -609,7 +628,12 @@ async fn test_purgatory_continues_working_after_restore() { | |||
| 609 | 628 | ||
| 610 | let event1 = create_state_event_with_refs(&keys, "repo1", &[("main", "abc123")]).unwrap(); | 629 | let event1 = create_state_event_with_refs(&keys, "repo1", &[("main", "abc123")]).unwrap(); |
| 611 | 630 | ||
| 612 | purgatory.add_state(event1.clone(), "repo1".to_string(), keys.public_key()); | 631 | purgatory.add_state( |
| 632 | event1.clone(), | ||
| 633 | "repo1".to_string(), | ||
| 634 | keys.public_key(), | ||
| 635 | false, | ||
| 636 | ); | ||
| 613 | 637 | ||
| 614 | // Save and restore | 638 | // Save and restore |
| 615 | purgatory.save_to_disk(&state_path).unwrap(); | 639 | purgatory.save_to_disk(&state_path).unwrap(); |
| @@ -620,7 +644,12 @@ async fn test_purgatory_continues_working_after_restore() { | |||
| 620 | // Add new events after restore | 644 | // Add new events after restore |
| 621 | let event2 = create_state_event_with_refs(&keys, "repo2", &[("main", "xyz789")]).unwrap(); | 645 | let event2 = create_state_event_with_refs(&keys, "repo2", &[("main", "xyz789")]).unwrap(); |
| 622 | 646 | ||
| 623 | purgatory2.add_state(event2.clone(), "repo2".to_string(), keys.public_key()); | 647 | purgatory2.add_state( |
| 648 | event2.clone(), | ||
| 649 | "repo2".to_string(), | ||
| 650 | keys.public_key(), | ||
| 651 | false, | ||
| 652 | ); | ||
| 624 | 653 | ||
| 625 | // Verify both old and new events work | 654 | // Verify both old and new events work |
| 626 | let (_, state_count, _) = purgatory2.count(); | 655 | let (_, state_count, _) = purgatory2.count(); |
| @@ -701,7 +730,7 @@ async fn test_purgatory_entries_expired_during_downtime() { | |||
| 701 | 730 | ||
| 702 | let event = create_state_event_with_refs(&keys, "repo1", &[("main", "abc123")]).unwrap(); | 731 | let event = create_state_event_with_refs(&keys, "repo1", &[("main", "abc123")]).unwrap(); |
| 703 | 732 | ||
| 704 | purgatory.add_state(event.clone(), "repo1".to_string(), keys.public_key()); | 733 | purgatory.add_state(event.clone(), "repo1".to_string(), keys.public_key(), false); |
| 705 | 734 | ||
| 706 | // Save to disk | 735 | // Save to disk |
| 707 | purgatory.save_to_disk(&state_path).unwrap(); | 736 | purgatory.save_to_disk(&state_path).unwrap(); |