thing-testkit tests: compare stored payloads from the snapshot
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a9dcab6516
commit
aa0dd94ec6
1 changed files with 7 additions and 6 deletions
|
|
@ -31,16 +31,17 @@ fn every_fixture_round_trips_through_the_contract() {
|
||||||
|
|
||||||
// Each record re-encodes to its stored payload.
|
// Each record re-encodes to its stored payload.
|
||||||
let cache = fixture.open();
|
let cache = fixture.open();
|
||||||
|
let stored = cache.snapshot_envelopes();
|
||||||
|
let payload = |kind: &str, key: String| {
|
||||||
|
stored.iter().find(|envelope| envelope.r#type == kind && envelope.key == key).unwrap().payload.clone()
|
||||||
|
};
|
||||||
for surface in &loaded.surfaces {
|
for surface in &loaded.surfaces {
|
||||||
let stored = cache.get_envelope::<SurfaceDocument>(&surface.record_key()).unwrap().unwrap();
|
assert_eq!(rmp_serde::to_vec(surface).unwrap(), payload("gamecult.thing.surface", surface.record_key()));
|
||||||
assert_eq!(rmp_serde::to_vec(surface).unwrap(), stored.payload);
|
|
||||||
}
|
}
|
||||||
for composition in &loaded.compositions {
|
for composition in &loaded.compositions {
|
||||||
let stored = cache.get_envelope::<CompositionDocument>(&composition.record_key()).unwrap().unwrap();
|
let key = composition.record_key();
|
||||||
assert_eq!(rmp_serde::to_vec(composition).unwrap(), stored.payload);
|
assert_eq!(rmp_serde::to_vec(composition).unwrap(), payload("gamecult.thing.composition", key));
|
||||||
}
|
}
|
||||||
assert_eq!(
|
|
||||||
cache.snapshot_envelopes().len(),
|
|
||||||
loaded.surfaces.len() + loaded.compositions.len() + loaded.catalogs.len(),
|
loaded.surfaces.len() + loaded.compositions.len() + loaded.catalogs.len(),
|
||||||
"{}: the store holds the documents and nothing else",
|
"{}: the store holds the documents and nothing else",
|
||||||
fixture.file_name()
|
fixture.file_name()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue