test: deepen and complete project-wide test coverage (#297)
* test: deepen coverage for health doctor provider and tunnels * test: add broad trait and module re-export coverage
This commit is contained in:
parent
79a6f180a8
commit
49fcc7a2c4
21 changed files with 1156 additions and 0 deletions
|
|
@ -66,3 +66,53 @@ pub trait Memory: Send + Sync {
|
|||
/// Health check
|
||||
async fn health_check(&self) -> bool;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn memory_category_display_outputs_expected_values() {
|
||||
assert_eq!(MemoryCategory::Core.to_string(), "core");
|
||||
assert_eq!(MemoryCategory::Daily.to_string(), "daily");
|
||||
assert_eq!(MemoryCategory::Conversation.to_string(), "conversation");
|
||||
assert_eq!(
|
||||
MemoryCategory::Custom("project_notes".into()).to_string(),
|
||||
"project_notes"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn memory_category_serde_uses_snake_case() {
|
||||
let core = serde_json::to_string(&MemoryCategory::Core).unwrap();
|
||||
let daily = serde_json::to_string(&MemoryCategory::Daily).unwrap();
|
||||
let conversation = serde_json::to_string(&MemoryCategory::Conversation).unwrap();
|
||||
|
||||
assert_eq!(core, "\"core\"");
|
||||
assert_eq!(daily, "\"daily\"");
|
||||
assert_eq!(conversation, "\"conversation\"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn memory_entry_roundtrip_preserves_optional_fields() {
|
||||
let entry = MemoryEntry {
|
||||
id: "id-1".into(),
|
||||
key: "favorite_language".into(),
|
||||
content: "Rust".into(),
|
||||
category: MemoryCategory::Core,
|
||||
timestamp: "2026-02-16T00:00:00Z".into(),
|
||||
session_id: Some("session-abc".into()),
|
||||
score: Some(0.98),
|
||||
};
|
||||
|
||||
let json = serde_json::to_string(&entry).unwrap();
|
||||
let parsed: MemoryEntry = serde_json::from_str(&json).unwrap();
|
||||
|
||||
assert_eq!(parsed.id, "id-1");
|
||||
assert_eq!(parsed.key, "favorite_language");
|
||||
assert_eq!(parsed.content, "Rust");
|
||||
assert_eq!(parsed.category, MemoryCategory::Core);
|
||||
assert_eq!(parsed.session_id.as_deref(), Some("session-abc"));
|
||||
assert_eq!(parsed.score, Some(0.98));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue