//! Every `.improv` document this repository ships must load (improvise-odbc). //! Why a DIRECTORY WALK and not a list: `context/test-evidence/tui.md`. use std::path::{Path, PathBuf}; fn shipped_documents() -> Vec { let root = Path::new(env!("CARGO_MANIFEST_DIR")); let mut found: Vec = ["examples", "web"] .iter() .flat_map(|dir| std::fs::read_dir(root.join(dir)).expect("a shipped-document directory")) .map(|entry| entry.expect("a readable directory entry").path()) // `extension()` of `x.improv.gz` is `gz`, so matching on the extension // alone would skip it and put back the hole this test closes. .filter(|p| { p.to_str() .is_some_and(|s| s.ends_with(".improv") || s.ends_with(".improv.gz")) }) .collect(); found.sort(); found } #[test] fn every_shipped_document_loads() { let documents = shipped_documents(); assert!( documents.len() >= 2, "precondition: the walk must find the documents that exist, got {documents:?}" ); for path in documents { let workbook = improvise::persistence::load(&path) .unwrap_or_else(|e| panic!("{} does not load: {e}", path.display())); assert!( workbook.views.contains_key(&workbook.active_view), "{} loads but its initial view {:?} is not one of {:?}", path.display(), workbook.active_view, workbook.views.keys().collect::>() ); } }