1pub mod audit_log;
13pub mod objects;
14pub mod objects_v74;
15pub mod objects_v75;
16pub mod objects_v76;
17pub mod objects_v77;
18pub mod objects_v78;
19pub mod objects_v79;
20pub mod objects_v80;
21pub mod serialization;
22
23pub const CATALOG_VERSION: u64 = 80;
29
30pub const MIN_CATALOG_VERSION: u64 = 74;
34
35#[cfg(test)]
36mod tests {
37 use std::collections::BTreeSet;
38 use std::fs;
39 use std::path::PathBuf;
40
41 use crate::{CATALOG_VERSION, MIN_CATALOG_VERSION};
42
43 #[mz_ore::test]
44 fn test_assert_snapshots_exist() {
45 let src_dir: PathBuf = [env!("CARGO_MANIFEST_DIR"), "src"].iter().collect();
46
47 let mut filenames: BTreeSet<_> = fs::read_dir(src_dir)
49 .expect("failed to read src dir")
50 .map(|entry| entry.expect("failed to read dir entry").file_name())
51 .map(|filename| filename.to_str().expect("utf8").to_string())
52 .filter(|filename| filename.starts_with("objects_v"))
53 .collect();
54
55 for version in MIN_CATALOG_VERSION..=CATALOG_VERSION {
57 let filename = format!("objects_v{version}.rs");
58 assert!(
59 filenames.remove(&filename),
60 "Missing snapshot for v{version}."
61 );
62 }
63
64 if !filenames.is_empty()
66 && filenames.remove(&format!("objects_v{}.proto", CATALOG_VERSION + 1))
67 {
68 panic!(
69 "Found snapshot for v{}, please also bump `CATALOG_VERSION`.",
70 CATALOG_VERSION + 1
71 )
72 }
73
74 assert!(
76 filenames.is_empty(),
77 "Found snapshots for unsupported catalog versions {filenames:?}.\n\
78 If you just increased `MIN_CATALOG_VERSION`, then please delete the old snapshots. \
79 If you created a new snapshot, please bump `CATALOG_VERSION`."
80 );
81 }
82
83 #[mz_ore::test]
84 fn test_assert_current_snapshot() {
85 let src_dir: PathBuf = [env!("CARGO_MANIFEST_DIR"), "src"].iter().collect();
86 let current_rs = src_dir.join("objects.rs");
87 let snapshot_rs = src_dir.join(format!("objects_v{CATALOG_VERSION}.rs"));
88
89 let current = fs::read_to_string(current_rs).expect("read current");
90 let snapshot = fs::read_to_string(snapshot_rs).expect("read snapshot");
91
92 similar_asserts::assert_eq!(current, snapshot);
97 }
98}