Skip to content

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

test(agent): add coverage for artifact file and migration helpers

Steven Enamakel5d1845b413e1
diff --git a/crates/openhuman-core/src/agent/artifacts/files_tests.rs b/crates/openhuman-core/src/agent/artifacts/files_tests.rs
index 7827f0a35d..e402d4304d 100644
--- a/crates/openhuman-core/src/agent/artifacts/files_tests.rs
+++ b/crates/openhuman-core/src/agent/artifacts/files_tests.rs
@@ -74,11 +74,8 @@ async fn new_artifact_is_written_to_the_files_folder_not_the_workspace() {
meta.file_root.as_deref(),
Some(files_dir.to_string_lossy().as_ref())
);
- // Metadata stays hidden in the workspace; no bytes land beside it.
- assert_eq!(
- names_in(&workspace.join("artifacts").join(&meta.id)),
- vec!["meta.json"]
- );
+ // The record is a document, not a file: no bytes land in the workspace.
+ assert!(!workspace.join("artifacts").join(&meta.id).exists());
}
#[tokio::test]
@@ -294,6 +291,7 @@ async fn a_legacy_record_still_resolves_under_the_workspace() {
let tmp = TempDir::new().unwrap();
let meta = legacy_meta("legacy-1", "legacy-1/old.txt");
save_artifact_meta(tmp.path(), &meta).await.unwrap();
+ std::fs::create_dir_all(tmp.path().join("artifacts/legacy-1")).unwrap();
std::fs::write(tmp.path().join("artifacts/legacy-1/old.txt"), b"old").unwrap();
assert_eq!(
diff --git a/crates/openhuman-core/src/agent/artifacts/migrate_tests.rs b/crates/openhuman-core/src/agent/artifacts/migrate_tests.rs
index 22a89adda3..fd52dc1120 100644
--- a/crates/openhuman-core/src/agent/artifacts/migrate_tests.rs
+++ b/crates/openhuman-core/src/agent/artifacts/migrate_tests.rs
@@ -28,7 +28,9 @@ async fn legacy(workspace: &Path, id: &str, name: &str, bytes: &[u8], status: Ar
save_artifact_args(workspace, id, &serde_json::json!({ "title": name }))
.await
.unwrap();
- std::fs::write(workspace.join("artifacts").join(id).join(name), bytes).unwrap();
+ let dir = workspace.join("artifacts").join(id);
+ std::fs::create_dir_all(&dir).unwrap();
+ std::fs::write(dir.join(name), bytes).unwrap();
}
fn legacy_path(workspace: &Path, id: &str, name: &str) -> PathBuf {