()
| 2607 | |
| 2608 | #[tokio::test(flavor = "multi_thread")] |
| 2609 | async 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")] |
| 2642 | async fn test_session_options_builders() { |
nothing calls this directly
no test coverage detected