summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-18 18:28:16 +0000
committeraur-build <aur-build@localhost>2026-11-18 18:28:16 +0000
commitfdd004c50de6131be193044ae40424d691425a81 (patch)
tree87f3ce369f943d6ac077b7af1252850d86082422 /tests
parent2a8ce53f6754217c8e24f92a7b13190b68708d7a (diff)
downloadaur-build-fdd004c50de6131be193044ae40424d691425a81.tar.gz
aur-build-fdd004c50de6131be193044ae40424d691425a81.zip
db, watch: two N+1s and a version rule with one owner
m-17. `watch::staleness::dependents_of` walked the index and asked for each package's recipe by name — one query per package, on the path that runs after every publish, with N equal to the size of the index. `db::index_recipes` returns the whole table in one query now. While there: a recipe that fails to parse is no longer treated as "does not depend on this package". An unreadable srcinfo used to hide a dependent from staleness by returning `None` into an `unwrap_or(false)`; now it is a reason to look. `db::builds::requeue_blocked` asked "is this name in the index?" once per dependency of every blocked build, inside the dispatcher's hot loop. The set of in-index names is read once per pass and tested in memory. Same answer, one query. m-18. `approved_but_unbuilt` assembled the version a human reads with two `CASE WHEN epoch='0'` expressions in SQL — a second, independent copy of the `epoch:pkgver-pkgrel` rule that `pkgver::full_version` owns. Two copies of a formatting rule is how the Attention page ends up describing versions differently from every other page. The query returns the parts; Rust formats them. A guard test fails if version-string concatenation reappears in SQL.
Diffstat (limited to 'tests')
-rw-r--r--tests/schema_ownership.rs29
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 {