1pub mod objects;
13pub mod objects_v74;
14pub mod objects_v75;
15pub mod objects_v76;
16pub mod objects_v77;
17pub mod objects_v78;
18pub mod objects_v79;
19pub mod objects_v80;
20pub mod objects_v81;
21pub mod objects_v82;
22pub mod objects_v83;
23pub mod objects_v84;
24pub mod objects_v85;
25pub mod objects_v86;
26pub mod objects_v87;
27pub mod objects_v88;
28pub mod objects_v89;
29pub mod objects_v90;
30pub mod objects_v91;
31pub mod objects_v92;
32pub mod objects_v93;
33pub mod objects_v94;
34pub mod objects_v95;
35
36impl From<String> for objects::StringWrapper {
37 fn from(value: String) -> Self {
38 objects::StringWrapper { inner: value }
39 }
40}
41
42pub const CATALOG_VERSION: u64 = 95;
48
49pub const MIN_CATALOG_VERSION: u64 = 74;
53
54#[cfg(test)]
55mod tests {
56 use std::collections::BTreeSet;
57 use std::fs;
58 use std::path::PathBuf;
59
60 use crate::{CATALOG_VERSION, MIN_CATALOG_VERSION};
61
62 #[mz_ore::test]
63 fn test_assert_snapshots_exist() {
64 let src_dir: PathBuf = [env!("CARGO_MANIFEST_DIR"), "src"].iter().collect();
65
66 let mut filenames: BTreeSet<_> = fs::read_dir(src_dir)
68 .expect("failed to read src dir")
69 .map(|entry| entry.expect("failed to read dir entry").file_name())
70 .map(|filename| filename.to_str().expect("utf8").to_string())
71 .filter(|filename| filename.starts_with("objects_v"))
72 .collect();
73
74 for version in MIN_CATALOG_VERSION..=CATALOG_VERSION {
76 let filename = format!("objects_v{version}.rs");
77 assert!(
78 filenames.remove(&filename),
79 "Missing snapshot for v{version}."
80 );
81 }
82
83 if !filenames.is_empty()
85 && filenames.remove(&format!("objects_v{}.proto", CATALOG_VERSION + 1))
86 {
87 panic!(
88 "Found snapshot for v{}, please also bump `CATALOG_VERSION`.",
89 CATALOG_VERSION + 1
90 )
91 }
92
93 assert!(
95 filenames.is_empty(),
96 "Found snapshots for unsupported catalog versions {filenames:?}.\n\
97 If you just increased `MIN_CATALOG_VERSION`, then please delete the old snapshots. \
98 If you created a new snapshot, please bump `CATALOG_VERSION`."
99 );
100 }
101
102 #[mz_ore::test]
103 fn test_assert_current_snapshot() {
104 let src_dir: PathBuf = [env!("CARGO_MANIFEST_DIR"), "src"].iter().collect();
105 let current_rs = src_dir.join("objects.rs");
106 let snapshot_rs = src_dir.join(format!("objects_v{CATALOG_VERSION}.rs"));
107
108 let current = fs::read_to_string(current_rs).expect("read current");
109 let snapshot = fs::read_to_string(snapshot_rs).expect("read snapshot");
110
111 similar_asserts::assert_eq!(current, snapshot);
116 }
117}