Skip to content

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

test(storage): assert backend behaviour instead of driver names

Steven Enamakel9f1ce81ef7d7
diff --git a/crates/openhuman-core/src/flows/catalog_storage_resource_tests.rs b/crates/openhuman-core/src/flows/catalog_storage_resource_tests.rs
index fb0e310fe6..eee48f4e49 100644
--- a/crates/openhuman-core/src/flows/catalog_storage_resource_tests.rs
+++ b/crates/openhuman-core/src/flows/catalog_storage_resource_tests.rs
@@ -59,7 +59,7 @@ async fn workspace_fd_lifetime_is_separate_from_catalog_callback_lifetime() {
for workspace in &workspaces {
let backend = crate::storage::local::backend_for(workspace.path())
.expect("open the temporary workspace default backend");
- assert_eq!(backend.driver(), "sqlite");
+ assert!(workspace.path().join("storage").exists());
drop(backend);
}
let after_backend_opens = open_fd_count();
diff --git a/crates/openhuman-core/src/storage/config_tests.rs b/crates/openhuman-core/src/storage/config_tests.rs
index 408267e648..a41c6364b9 100644
--- a/crates/openhuman-core/src/storage/config_tests.rs
+++ b/crates/openhuman-core/src/storage/config_tests.rs
@@ -78,7 +78,6 @@ async fn the_default_url_opens_in_directory_mode() {
let backend = crate::storage::open(&default_url(dir.path()))
.await
.unwrap();
- assert_eq!(backend.driver(), "sqlite");
// Directory mode: the directory holds the database file.
assert!(dir.path().join(DEFAULT_DIR).exists());
}
diff --git a/crates/openhuman-core/src/storage/mod_tests.rs b/crates/openhuman-core/src/storage/mod_tests.rs
index 8382381cba..2d32a67a48 100644
--- a/crates/openhuman-core/src/storage/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/mod_tests.rs
@@ -79,7 +79,17 @@ fn the_default_url_is_a_directory_under_the_workspace() {
#[tokio::test]
async fn opens_memory_and_refuses_garbage() {
let backend = open("memory").await.unwrap();
- assert_eq!(backend.driver(), "memory");
+ let scope = backend.for_scope(&Scope::local()).unwrap();
+ let docs = Arc::clone(scope.documents());
+ block_on(async move {
+ docs.ensure_collection(&CollectionSpec::new("probe"))
+ .await?;
+ docs.put("probe", "opened", serde_json::json!({"ok": true}), Precondition::Absent)
+ .await?;
+ assert_eq!(docs.get("probe", "opened").await?.unwrap().doc["ok"], true);
+ Ok(())
+ })
+ .unwrap();
assert!(open("ftp://nope").await.is_err());
}
@@ -226,7 +236,7 @@ fn only_mongodb_and_sqlite_have_cross_process_cas() {
}
#[tokio::test]
-async fn the_driver_name_check_agrees_with_what_each_backend_claims() {
+async fn local_drivers_do_not_claim_cross_process_cas() {
let dir = tempfile::tempdir().unwrap();
for url in [
"memory".to_string(),
@@ -234,11 +244,9 @@ async fn the_driver_name_check_agrees_with_what_each_backend_claims() {
format!("file:{}", dir.path().join("files").display()),
] {
let backend = open(&url).await.unwrap();
- assert_eq!(
- backend_has_cross_process_cas(backend.as_ref()),
- driver_has_cross_process_cas(backend.driver()),
- "{}",
- backend.driver()
+ assert!(
+ !backend_has_cross_process_cas(backend.as_ref()),
+ "{url} is a local driver"
);
}
}