diff options
Diffstat (limited to 'tests/schema_ownership.rs')
| -rw-r--r-- | tests/schema_ownership.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/schema_ownership.rs b/tests/schema_ownership.rs index e2904f4..dac93d6 100644 --- a/tests/schema_ownership.rs +++ b/tests/schema_ownership.rs @@ -72,6 +72,35 @@ fn no_sql_statements_outside_the_db_module() { ); } +/// m-18: the version a human reads is `pkgver::full_version`'s to produce — +/// `epoch:pkgver-pkgrel`, with the epoch omitted when it is `0` or empty. That +/// rule used to exist twice, once in Rust and once as a `CASE WHEN epoch='0'` +/// inside `approved_but_unbuilt`, where a change to one would silently make the +/// Attention page disagree with every other page about what a version looks +/// like. SQL selects the parts; Rust formats them. +#[test] +fn only_rust_formats_a_version() { + let root = Path::new(env!("CARGO_MANIFEST_DIR")); + let mut files = Vec::new(); + rust_files(&root.join("src"), &mut files); + let offenders: Vec<String> = files + .iter() + .flat_map(|f| { + let text = std::fs::read_to_string(f).unwrap(); + text.lines() + .filter(|l| !l.trim_start().starts_with("//")) + .filter(|l| l.contains("epoch||") || l.contains("||'-'||") || l.contains("pkgver||")) + .map(|l| format!(" {}: {}", f.strip_path(root), l.trim())) + .collect::<Vec<_>>() + }) + .collect(); + assert!( + offenders.is_empty(), + "version formatting belongs to `pkgver::full_version`, not to SQL (m-18):\n{}", + offenders.join("\n") + ); +} + /// `src/db/queries.rs` → `db/queries.rs`, so the failure message points at the /// module rather than an absolute path. trait StripPath { |
