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