Add InMemoryStore create_run retry and conflict test

Covers the idempotent retry path (same run_id + same created_at) and
the conflict rejection path (same run_id + different created_at returns
RunAlreadyExists). This was already tested in the SlateStore suite but
missing from the InMemoryStore tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-03-28 00:28:29 -04:00
parent c6c227684c
commit 67f1773d4e
No known key found for this signature in database

View file

@ -1049,4 +1049,24 @@ mod tests {
store.delete_run("run-1").await.unwrap();
assert!(store.open_run("run-1").await.unwrap().is_none());
}
#[tokio::test]
async fn create_run_allows_retry_and_rejects_conflict() {
let store = InMemoryStore::default();
let ts = dt("2026-03-27T12:00:00Z");
// First create succeeds.
store.create_run("run-1", ts).await.unwrap();
// Retry with exact same created_at succeeds (idempotent).
store.create_run("run-1", ts).await.unwrap();
// Different created_at for the same run_id is rejected.
let different_ts = dt("2026-03-27T12:00:01Z");
match store.create_run("run-1", different_ts).await {
Err(StoreError::RunAlreadyExists(_)) => {} // expected
Err(other) => panic!("expected RunAlreadyExists, got: {other:?}"),
Ok(_) => panic!("expected RunAlreadyExists, but create_run succeeded"),
}
}
}