()
| 807 | |
| 808 | #[tokio::test] |
| 809 | async fn test_write_and_commit() { |
| 810 | let file_io = test_file_io(); |
| 811 | let table_path = "memory:/test_table_write"; |
| 812 | setup_dirs(&file_io, table_path).await; |
| 813 | |
| 814 | let table = test_table(&file_io, table_path); |
| 815 | let mut table_write = TableWrite::new(&table, "test-user".to_string()).unwrap(); |
| 816 | |
| 817 | let batch = make_batch(vec![1, 2, 3], vec![10, 20, 30]); |
| 818 | table_write.write_arrow_batch(&batch).await.unwrap(); |
| 819 | |
| 820 | let messages = table_write.prepare_commit().await.unwrap(); |
| 821 | assert_eq!(messages.len(), 1); |
| 822 | assert_eq!(messages[0].bucket, 0); |
| 823 | assert_eq!(messages[0].new_files.len(), 1); |
| 824 | assert_eq!(messages[0].new_files[0].row_count, 3); |
| 825 | |
| 826 | // Commit and verify snapshot |
| 827 | let commit = TableCommit::new(table, "test-user".to_string()); |
| 828 | commit.commit(messages).await.unwrap(); |
| 829 | |
| 830 | let snap_manager = SnapshotManager::new(file_io.clone(), table_path.to_string()); |
| 831 | let snapshot = snap_manager.get_latest_snapshot().await.unwrap().unwrap(); |
| 832 | assert_eq!(snapshot.id(), 1); |
| 833 | assert_eq!(snapshot.total_record_count(), Some(3)); |
| 834 | } |
| 835 | |
| 836 | #[test] |
| 837 | fn test_allows_append_blob_table() { |
nothing calls this directly
no test coverage detected