feat(core): settle the Store trait (flush, is_empty, conformance suite)
This commit is contained in:
@@ -17,3 +17,8 @@ rand = "0.8"
|
||||
|
||||
[dev-dependencies]
|
||||
proptest = "1"
|
||||
|
||||
[features]
|
||||
# Re-export tines-core's std-free conformance suite so a backend can exercise
|
||||
# CappedStore against it: `cargo test --features conformance`.
|
||||
conformance = ["tines-core/conformance"]
|
||||
|
||||
@@ -80,4 +80,41 @@ impl Store for CappedStore {
|
||||
fn trim(&mut self, policy: &TrimPolicy, now: Tick) -> usize {
|
||||
self.inner.trim(policy, now)
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
self.inner.is_empty()
|
||||
}
|
||||
|
||||
fn flush(&mut self, now: Tick) -> Result<(), StoreError> {
|
||||
self.inner.flush(now)
|
||||
}
|
||||
}
|
||||
|
||||
/// Conformance-suite shim for [`CappedStore`].
|
||||
///
|
||||
/// `CappedStore` is a capacity-bounded wrapper over [`MemStore`], so it
|
||||
/// inherits the memory backend's conformance by delegating; this shim proves
|
||||
/// the delegation is complete. Run with:
|
||||
/// `cargo test -p tines-sim --features conformance`.
|
||||
#[cfg(all(test, feature = "conformance"))]
|
||||
mod conformance_tests {
|
||||
use super::CappedStore;
|
||||
use tines_core::store_conformance;
|
||||
|
||||
fn make() -> impl FnMut() -> CappedStore {
|
||||
|| CappedStore::default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn capped_conforms() {
|
||||
store_conformance::insert_get(make());
|
||||
store_conformance::dedupe(make());
|
||||
store_conformance::age_lineage(make());
|
||||
store_conformance::saturating_ticks(make());
|
||||
store_conformance::release_surviving_get(make());
|
||||
store_conformance::sig_round_trip(make());
|
||||
store_conformance::trim_order(make());
|
||||
store_conformance::no_tombstones(make());
|
||||
store_conformance::idempotent_flush(make());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user