Skip to content

Commit

Permalink
complete test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Jul 17, 2023
1 parent e96fb23 commit 8be698a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions analytic_engine/src/table/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,22 +894,37 @@ pub mod tests {

#[test]
fn test_manifest_snapshot_trigger() {
// When snapshot_every_n_updates is not zero.
let table_data = TableDataMocker::default()
.manifest_snapshot_every_n_updates(5)
.build();
// When no updates yet, result should be false.
assert!(!table_data.should_do_manifest_snapshot());

// Normal case.
table_data.increase_manifest_updates(5);
assert!(table_data.should_do_manifest_snapshot());
check_manifest_snapshot_trigger(&table_data);
// Reset and check again.
table_data.reset_manifest_updates();
check_manifest_snapshot_trigger(&table_data);

// When snapshot_every_n_updates is set to zero, result should be always false.
// When snapshot_every_n_updates is set to zero.
let table_data = TableDataMocker::default()
.manifest_snapshot_every_n_updates(0)
.build();
assert!(!table_data.should_do_manifest_snapshot());
table_data.increase_manifest_updates(5);
assert!(!table_data.should_do_manifest_snapshot());
table_data.increase_manifest_updates(5);
assert!(!table_data.should_do_manifest_snapshot());
}

fn check_manifest_snapshot_trigger(table_data: &TableData) {
// When no updates yet, result should be false.
assert!(!table_data.should_do_manifest_snapshot());

// Eq case.
table_data.increase_manifest_updates(5);
assert!(table_data.should_do_manifest_snapshot());

// Greater case.
table_data.increase_manifest_updates(5);
assert!(table_data.should_do_manifest_snapshot());
}
}

0 comments on commit 8be698a

Please sign in to comment.