MCPcopy Create free account
hub / github.com/AI45Lab/Code / test_file_session_store_persistence

Function test_file_session_store_persistence

core/src/agent_api/tests.rs:2609–2639  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2607
2608#[tokio::test(flavor = "multi_thread")]
2609async fn test_file_session_store_persistence() {
2610 let dir = tempfile::TempDir::new().unwrap();
2611 let store = Arc::new(
2612 crate::store::FileSessionStore::new(dir.path())
2613 .await
2614 .unwrap(),
2615 );
2616 let agent = Agent::from_config(test_config()).await.unwrap();
2617
2618 // Save
2619 let opts = SessionOptions::new()
2620 .with_session_store(store.clone())
2621 .with_session_id("file-persist");
2622 let session = agent
2623 .session("/tmp/test-ws-file-persist", Some(opts))
2624 .unwrap();
2625 {
2626 let mut h = session.history.write().unwrap();
2627 h.push(Message::user("test message"));
2628 }
2629 session.save().await.unwrap();
2630
2631 // Load from a fresh store instance pointing to same dir
2632 let store2 = Arc::new(
2633 crate::store::FileSessionStore::new(dir.path())
2634 .await
2635 .unwrap(),
2636 );
2637 let data = store2.load("file-persist").await.unwrap().unwrap();
2638 assert_eq!(data.messages.len(), 1);
2639}
2640
2641#[tokio::test(flavor = "multi_thread")]
2642async fn test_session_options_builders() {

Callers

nothing calls this directly

Calls 9

pathMethod · 0.80
with_session_storeMethod · 0.80
writeMethod · 0.80
test_configFunction · 0.70
with_session_idMethod · 0.45
cloneMethod · 0.45
sessionMethod · 0.45
saveMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected