Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(storage): update import state tests

Steven Enamakel4eb3e2c82a46
diff --git a/crates/openhuman-core/src/storage/import/mod_tests.rs b/crates/openhuman-core/src/storage/import/mod_tests.rs
index 79c47d1b92..8809342202 100644
--- a/crates/openhuman-core/src/storage/import/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/import/mod_tests.rs
@@ -170,10 +170,11 @@ fn an_import_claimed_by_another_process_waits_for_it_and_does_not_repeat_it() {
&markers,
MARKER_OWNER,
&step.clone(),
- |_| {
- held_tx.send(()).unwrap();
- std::thread::sleep(std::time::Duration::from_millis(400));
- crate::storage::import_state::set_done(&markers, MARKER_OWNER, &step)
+ |condition| {
+ held_tx.send(()).unwrap();
+ std::thread::sleep(std::time::Duration::from_millis(400));
+ let claimed_markers = markers.conditioned(condition)?;
+ crate::storage::import_state::set_done(&claimed_markers, MARKER_OWNER, &step)
},
)
.unwrap()
diff --git a/crates/openhuman-core/src/storage/import_state_tests.rs b/crates/openhuman-core/src/storage/import_state_tests.rs
index 292ec9910f..a30e85b751 100644
--- a/crates/openhuman-core/src/storage/import_state_tests.rs
+++ b/crates/openhuman-core/src/storage/import_state_tests.rs
@@ -271,8 +271,8 @@ fn takeover_and_lost_heartbeat_refuse_the_stale_payload_write() {
std::thread::sleep(Duration::from_millis(150));
let stale_repo = worker_repo.conditioned(condition)?;
let attempted = stale_repo.run(|docs| async move {
- docs.ensure_collection(&CollectionSpec::new("claim_payload"))
- .await?;
+ let spec = CollectionSpec::new("claim_payload");
+ docs.ensure_collection(&spec).await?;
docs.put(
"claim_payload",
"stale",
@@ -282,7 +282,10 @@ fn takeover_and_lost_heartbeat_refuse_the_stale_payload_write() {
.await
.map(|_| ())
});
- assert!(attempted.is_err(), "the expired claim cannot write its payload");
+ assert!(
+ attempted.is_err(),
+ "the expired claim cannot write its payload"
+ );
Ok(())
})
});
@@ -293,7 +296,10 @@ fn takeover_and_lost_heartbeat_refuse_the_stale_payload_write() {
.unwrap()
.expect("takeover replaces the old claim");
takeover_tx.send(()).unwrap();
- assert!(worker.join().unwrap().is_err(), "lost heartbeat fails the import");
+ assert!(
+ worker.join().unwrap().is_err(),
+ "lost heartbeat fails the import"
+ );
release(&repo, &replacement).unwrap();
let payload = repo