mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-25 14:53:34 +00:00
* feat: Import OpenClaw memory, history and settings * review fixes * fix: address remaining code quality issues 1. Remove dead import_conversation() function - replaced by import_conversation_atomic() 2. Improve non-UTF-8 filename handling in list_agent_dbs() - log warning instead of silent 'unknown' 3. Remove emojis from CLI output per project style guide Co-Authored-By: Claude Haiku 4.5 <[email protected]> --------- Co-authored-by: Claude Haiku 4.5 <[email protected]>
70 lines
2.0 KiB
Rust
70 lines
2.0 KiB
Rust
//! Integration tests for OpenClaw import functionality.
|
|
|
|
#![cfg(feature = "import")]
|
|
|
|
#[cfg(feature = "import")]
|
|
mod import_tests {
|
|
use ironclaw::import::openclaw::reader::{OpenClawConfig, OpenClawMemoryChunk};
|
|
use ironclaw::import::{ImportError, ImportStats};
|
|
|
|
#[test]
|
|
fn test_import_stats_is_empty() {
|
|
let stats = ImportStats::default();
|
|
assert!(stats.is_empty());
|
|
assert_eq!(stats.total_imported(), 0);
|
|
}
|
|
|
|
#[test]
|
|
fn test_import_stats_total_imported() {
|
|
let stats = ImportStats {
|
|
documents: 5,
|
|
chunks: 10,
|
|
conversations: 2,
|
|
messages: 50,
|
|
settings: 3,
|
|
secrets: 1,
|
|
..ImportStats::default()
|
|
};
|
|
|
|
assert!(!stats.is_empty());
|
|
assert_eq!(stats.total_imported(), 71);
|
|
}
|
|
|
|
#[test]
|
|
fn test_import_error_display() {
|
|
let err = ImportError::ConfigParse("test error".to_string());
|
|
assert_eq!(err.to_string(), "JSON5 parse error: test error");
|
|
|
|
let err = ImportError::Database("db error".to_string());
|
|
assert_eq!(err.to_string(), "Database error: db error");
|
|
}
|
|
|
|
#[test]
|
|
fn test_openclaw_config_construction() {
|
|
let config = OpenClawConfig {
|
|
llm: None,
|
|
embeddings: None,
|
|
other_settings: std::collections::HashMap::new(),
|
|
};
|
|
|
|
assert!(config.llm.is_none());
|
|
assert!(config.embeddings.is_none());
|
|
assert!(config.other_settings.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn test_memory_chunk_construction() {
|
|
let chunk = OpenClawMemoryChunk {
|
|
path: "test/doc.md".to_string(),
|
|
content: "Test content".to_string(),
|
|
embedding: Some(vec![0.1, 0.2, 0.3]),
|
|
chunk_index: 0,
|
|
};
|
|
|
|
assert_eq!(chunk.path, "test/doc.md");
|
|
assert_eq!(chunk.content, "Test content");
|
|
assert!(chunk.embedding.is_some());
|
|
assert_eq!(chunk.chunk_index, 0);
|
|
}
|
|
}
|