use event_integration::document::document_event::DocumentEventTest; use event_integration::document_data_from_document_doc_state; use std::time::Duration; use tokio::task::yield_now; #[tokio::test] async fn create_document_snapshot_test() { let test = DocumentEventTest::new().await; let view = test.create_document().await; for i in 0..60 { test.insert_index(&view.id, &i.to_string(), 1, None).await; yield_now().await; } // wait for the snapshot to save to disk tokio::time::sleep(Duration::from_secs(2)).await; let snapshot_metas = test.get_document_snapshot_metas(&view.id).await; assert_eq!(snapshot_metas.len(), 1); for snapshot_meta in snapshot_metas { let data = test.get_document_snapshot(snapshot_meta).await; let _ = document_data_from_document_doc_state(&view.id, data.encoded_v1); } } #[tokio::test] async fn maximum_document_snapshot_tests() { let test = DocumentEventTest::new().await; let view = test.create_document().await; for i in 0..400 { test.insert_index(&view.id, &i.to_string(), 1, None).await; if i % 50 == 0 { tokio::time::sleep(Duration::from_secs(1)).await; } yield_now().await; } // wait for the snapshot to save to disk tokio::time::sleep(Duration::from_secs(1)).await; let snapshot_metas = test.get_document_snapshot_metas(&view.id).await; // The default maximum snapshot is 5 assert_eq!(snapshot_metas.len(), 5); }