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