Skip to content

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

refactor(config): move memory config tests into their own module

Steven Enamakel8bcc6d6c0b46
diff --git a/crates/openhuman-core/src/config/schema/memory_tests.rs b/crates/openhuman-core/src/config/schema/memory_tests.rs
index 63b8fc7add..3931421a8c 100644
--- a/crates/openhuman-core/src/config/schema/memory_tests.rs
+++ b/crates/openhuman-core/src/config/schema/memory_tests.rs
@@ -140,8 +140,8 @@ target = "rust"
[[sources]]
id = "good"
-kind = "rss"
-target = "https://example.com/feed.xml"
+kind = "folder"
+target = "/notes"
"#,
)
.expect("one bad entry does not fail the section");
@@ -150,6 +150,57 @@ target = "https://example.com/feed.xml"
assert_eq!(config.sources[0].label, "", "label defaults to empty");
}
+#[test]
+fn drops_sources_of_removed_network_kinds_and_keeps_local_ones() {
+ let config: MemoryConfig = toml::from_str(
+ r#"
+[[sources]]
+id = "src-composio"
+kind = "composio"
+target = "gmail"
+
+[[sources]]
+id = "src-link"
+kind = "link"
+target = "https://example.com"
+
+[[sources]]
+id = "src-github"
+kind = "github"
+target = "o/r"
+
+[[sources]]
+id = "src-rss"
+kind = "rss"
+target = "https://example.com/feed.xml"
+
+[[sources]]
+id = "src-folder"
+kind = "folder"
+target = "/notes"
+
+[[sources]]
+id = "src-file"
+kind = "file"
+target = "/notes/a.md"
+"#,
+ )
+ .expect("removed kinds must not fail the section");
+ let ids: Vec<&str> = config.sources.iter().map(|s| s.id.as_str()).collect();
+ assert_eq!(ids, ["src-folder", "src-file"]);
+}
+
+#[test]
+fn only_folder_and_file_remain_as_source_kinds() {
+ assert_eq!(
+ MemorySourceKind::ALL,
+ [MemorySourceKind::Folder, MemorySourceKind::File]
+ );
+ for removed in ["composio", "link", "github", "rss"] {
+ assert_eq!(MemorySourceKind::parse(removed), None, "{removed}");
+ }
+}
+
#[test]
fn endpoint_for_ignores_blank_and_missing_endpoints() {
let mut config = MemoryConfig::default();
@@ -190,7 +241,7 @@ fn source_kind_round_trips_its_wire_names() {
}
#[test]
-fn migrates_every_mappable_legacy_kind() {
+fn migrates_the_local_legacy_kinds() {
let cases = [
(
json!({"id":"a","kind":"folder","path":"/p"}),
@@ -202,26 +253,6 @@ fn migrates_every_mappable_legacy_kind() {
MemorySourceKind::File,
"/f.md",
),
- (
- json!({"id":"c","kind":"web_page","url":"https://w"}),
- MemorySourceKind::Link,
- "https://w",
- ),
- (
- json!({"id":"d","kind":"github_repo","url":"o/r"}),
- MemorySourceKind::Github,
- "o/r",
- ),
- (
- json!({"id":"e","kind":"rss_feed","url":"https://f"}),
- MemorySourceKind::Rss,
- "https://f",
- ),
- (
- json!({"id":"f","kind":"composio","toolkit":"gmail"}),
- MemorySourceKind::Composio,
- "gmail",
- ),
];
for (legacy, kind, target) in cases {
let migrated = migrate_legacy_source(&legacy).expect("mappable kind migrates");
@@ -246,6 +277,10 @@ fn migration_drops_unmappable_disabled_and_incomplete_entries() {
for legacy in [
json!({"id":"t","kind":"twitter_query","query":"rust"}),
json!({"id":"c","kind":"conversation"}),
+ json!({"id":"w","kind":"web_page","url":"https://w"}),
+ json!({"id":"g","kind":"github_repo","url":"o/r"}),
+ json!({"id":"r","kind":"rss_feed","url":"https://f"}),
+ json!({"id":"k","kind":"composio","toolkit":"gmail"}),
json!({"id":"x","kind":"folder","path":"/p","enabled":false}),
json!({"id":"y","kind":"folder"}),
json!({"kind":"folder","path":"/p"}),