use kanban_domain::export::AllBoardsExport;
use kanban_persistence::StoreRegistry;
use kanban_service::StoreManager;
fn manager() -> StoreManager {
let mut registry = StoreRegistry::new();
registry.register(Box::new(kanban_persistence_json::JsonStoreFactory));
StoreManager::new(registry)
}
#[tokio::test(flavor = "multi_thread")]
async fn test_export_to_sqlite_succeeds_and_creates_file() {
let dir = tempfile::tempdir().unwrap();
let output = dir.path().join("out.sqlite").to_string_lossy().to_string();
manager()
.export_to_sqlite(AllBoardsExport::empty(), &output)
.await
.expect("export_to_sqlite must succeed");
assert!(
std::path::Path::new(&output).exists(),
"exported sqlite file must be created on disk"
);
}
#[tokio::test(flavor = "multi_thread")]
async fn test_export_to_sqlite_result_is_readable_via_open_sqlite() {
use kanban_core::AppConfig;
let dir = tempfile::tempdir().unwrap();
let output = dir.path().join("out.sqlite").to_string_lossy().to_string();
manager()
.export_to_sqlite(AllBoardsExport::empty(), &output)
.await
.expect("export_to_sqlite must succeed");
let ctx = kanban_service::open_context(&output, AppConfig::default())
.await
.expect("open_context must succeed on exported file");
assert_eq!(ctx.boards().unwrap().len(), 0);
}