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

Function test_session_save_with_history

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

Source from the content-addressed store, hash-verified

2140
2141#[tokio::test(flavor = "multi_thread")]
2142async fn test_session_save_with_history() {
2143 let store = Arc::new(crate::store::MemorySessionStore::new());
2144 let agent = Agent::from_config(test_config()).await.unwrap();
2145
2146 let opts = SessionOptions::new()
2147 .with_session_store(store.clone())
2148 .with_session_id("history-test");
2149 let session = agent.session("/tmp/test-ws-hist", Some(opts)).unwrap();
2150
2151 // Manually inject history
2152 {
2153 let mut h = session.history.write().unwrap();
2154 h.push(Message::user("Hello"));
2155 h.push(Message::user("How are you?"));
2156 }
2157
2158 session.save().await.unwrap();
2159
2160 let data = store.load("history-test").await.unwrap().unwrap();
2161 assert_eq!(data.messages.len(), 2);
2162}
2163
2164#[tokio::test(flavor = "multi_thread")]
2165async fn test_resume_session() {

Callers

nothing calls this directly

Calls 8

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