mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-09 01:35:18 +02:00
Strengthen cleanup-then-optimize sequencing test with postconditions
Reviewer feedback on PR #62: the original `cleanup_then_optimize_succeed_in_sequence` only unwrapped both calls and asserted nothing, so it didn't validate the claimed sequencing behavior. The concern that motivates the test is that cleanup destroys version history and optimize on a freshly-cleaned table could trip on dropped fragment refs or stale manifests. Rename to `cleanup_then_optimize_preserves_rows_and_table_remains_writable` and add three concrete postconditions: row counts in both Person and Company tables survive the sequence; the head remains readable; and a subsequent merge load still succeeds.
This commit is contained in:
parent
57a62756c5
commit
a9c4423b82
1 changed files with 20 additions and 1 deletions
|
|
@ -123,10 +123,21 @@ async fn cleanup_older_than_zero_preserves_head() {
|
|||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cleanup_then_optimize_succeed_in_sequence() {
|
||||
async fn cleanup_then_optimize_preserves_rows_and_table_remains_writable() {
|
||||
// Cleanup destroys version history; the concern is that subsequent
|
||||
// optimize on a freshly-cleaned table could trip over dropped fragment
|
||||
// refs or stale manifests. Assert the sequence preserves row content,
|
||||
// leaves head readable, and doesn't break a subsequent write.
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut db = init_and_load(&dir).await;
|
||||
|
||||
let people_before = count_rows(&db, "node:Person").await;
|
||||
let companies_before = count_rows(&db, "node:Company").await;
|
||||
assert!(
|
||||
people_before > 0 && companies_before > 0,
|
||||
"fixture should seed both Person and Company rows"
|
||||
);
|
||||
|
||||
db.cleanup(CleanupPolicyOptions {
|
||||
keep_versions: Some(1),
|
||||
older_than: None,
|
||||
|
|
@ -134,4 +145,12 @@ async fn cleanup_then_optimize_succeed_in_sequence() {
|
|||
.await
|
||||
.unwrap();
|
||||
db.optimize().await.unwrap();
|
||||
|
||||
// Head is preserved through both ops.
|
||||
assert_eq!(count_rows(&db, "node:Person").await, people_before);
|
||||
assert_eq!(count_rows(&db, "node:Company").await, companies_before);
|
||||
|
||||
// Table is still writable after the cleanup+optimize sequence.
|
||||
load_jsonl(&mut db, TEST_DATA, LoadMode::Merge).await.unwrap();
|
||||
assert_eq!(count_rows(&db, "node:Person").await, people_before);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue