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 objects_v81;
22pub mod objects_v82;
23pub mod objects_v83;
24pub mod objects_v84;
25pub mod objects_v85;
26pub mod objects_v86;
27pub mod objects_v87;
28pub mod objects_v88;
29pub mod objects_v89;
30pub mod serialization;
31
32pub const CATALOG_VERSION: u64 = 89;
38
39pub const MIN_CATALOG_VERSION: u64 = 74;
43
44#[cfg(test)]
45mod tests {
46 use std::collections::BTreeSet;
47 use std::fs;
48 use std::path::PathBuf;
49
50 use crate::{CATALOG_VERSION, MIN_CATALOG_VERSION};
51
52 #[mz_ore::test]
53 fn test_assert_snapshots_exist() {
54 let src_dir: PathBuf = [env!("CARGO_MANIFEST_DIR"), "src"].iter().collect();
55
56 let mut filenames: BTreeSet<_> = fs::read_dir(src_dir)
58 .expect("failed to read src dir")
59 .map(|entry| entry.expect("failed to read dir entry").file_name())
60 .map(|filename| filename.to_str().expect("utf8").to_string())
61 .filter(|filename| filename.starts_with("objects_v"))
62 .collect();
63
64 for version in MIN_CATALOG_VERSION..=CATALOG_VERSION {
66 let filename = format!("objects_v{version}.rs");
67 assert!(
68 filenames.remove(&filename),
69 "Missing snapshot for v{version}."
70 );
71 }
72
73 if !filenames.is_empty()
75 && filenames.remove(&format!("objects_v{}.proto", CATALOG_VERSION + 1))
76 {
77 panic!(
78 "Found snapshot for v{}, please also bump `CATALOG_VERSION`.",
79 CATALOG_VERSION + 1
80 )
81 }
82
83 assert!(
85 filenames.is_empty(),
86 "Found snapshots for unsupported catalog versions {filenames:?}.\n\
87 If you just increased `MIN_CATALOG_VERSION`, then please delete the old snapshots. \
88 If you created a new snapshot, please bump `CATALOG_VERSION`."
89 );
90 }
91
92 #[mz_ore::test]
93 fn test_assert_current_snapshot() {
94 let src_dir: PathBuf = [env!("CARGO_MANIFEST_DIR"), "src"].iter().collect();
95 let current_rs = src_dir.join("objects.rs");
96 let snapshot_rs = src_dir.join(format!("objects_v{CATALOG_VERSION}.rs"));
97
98 let current = fs::read_to_string(current_rs).expect("read current");
99 let snapshot = fs::read_to_string(snapshot_rs).expect("read snapshot");
100
101 similar_asserts::assert_eq!(current, snapshot);
106 }
107}