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