summaryrefslogtreecommitdiffstats
path: root/tests/common
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-17 21:19:35 +0000
committeraur-build <aur-build@localhost>2026-11-17 21:19:35 +0000
commitf586d11f6a1711145ba4804787217a1bab58751d (patch)
tree3a8cd7d4a3d4097e315907c63e687bd243e8e686 /tests/common
parentfd3ecf91686b11feea078531baeddb60e6941116 (diff)
downloadaur-build-f586d11f6a1711145ba4804787217a1bab58751d.tar.gz
aur-build-f586d11f6a1711145ba4804787217a1bab58751d.zip
feat: AUR mirror watcher, recipe parsing, candidate creation
The detection path (§5.1, §5.1a, §5.3, §7.1): * git helpers, all subprocess git in one auditable place. Mirrors are cloned with --mirror and polled with git ls-remote, fetching only when the tip actually moved; --no-prune keeps history we may need forever. * .SRCINFO parsing (authoritative) with a PKGBUILD fallback, and source=() parsing that keeps VCS kind, #commit/#tag/#branch refs and the filename:: form. * recipe_hash over the whole snapshot tree, so a shipped patch is part of the recipe and cannot change silently. * source digest resolution: declared checksums are trusted-as-declared (makepkg enforces them, no bandwidth), local files are hashed from the mirror, and SKIP sources are downloaded and stream-hashed into the content-addressed source cache. Detection always re-fetches SKIP sources — answering from our own cache would defeat drift detection. * candidate creation with base = current_accepted_release, collapse in place while unviewed, supersede only once a human has looked, and a previously rejected identity is not re-raised. * non-publishable change handling (I11): unchanged version string means no review, but never silence — recipe drift and pin drift become notices, and a changed digest on a remote source with an unchanged version becomes a high-severity integrity_alert. Also vercmp + dep-string parsing with the ALPM test vectors, and the approval record with optimistic concurrency (§7.1a) that the CLI and web layers will both call. 16 detection tests against real file:// git fixtures, incl. I2 across three unattended detections and I11 for all three drift kinds. Part of P0 (DESIGN.md §17).
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/mod.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 4cf78ec..b598b80 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -73,6 +73,54 @@ impl Env {
.unwrap()
}
+ /// Stand in for the build+publish path: turn an approved candidate into a
+ /// published release and move the accepted pointer. The real path lives in
+ /// `pipeline`; detection tests need an accepted base without a build.
+ pub fn accept_as_release(&self, candidate_id: i64) -> i64 {
+ let at = "2026-01-01T00:00:00Z";
+ self.db
+ .writer
+ .tx(move |tx| {
+ tx.execute(
+ "INSERT INTO approval (candidate_id, base_release_id, decided_at, decision,
+ risk_level, diff_digest, identity_hash)
+ SELECT id, base_release_id, ?2, 'approved', risk_level, diff_digest, identity_hash
+ FROM candidate WHERE id=?1",
+ rusqlite::params![candidate_id, at],
+ )?;
+ let approval_id = tx.last_insert_rowid();
+ tx.execute(
+ "INSERT INTO release (pkgbase_id, candidate_id, approval_id, aur_commit, recipe_hash,
+ upstream_pins_json, source_digests_json, epoch, pkgver, pkgrel,
+ state, published_at, created_at)
+ SELECT c.pkgbase_id, c.id, ?2, s.aur_commit, s.recipe_hash, c.upstream_pins_json,
+ c.source_digests_json, c.epoch, c.pkgver, c.pkgrel,
+ 'published', ?3, ?3
+ FROM candidate c JOIN snapshot s ON s.id = c.snapshot_id WHERE c.id=?1",
+ rusqlite::params![candidate_id, approval_id, at],
+ )?;
+ let release_id = tx.last_insert_rowid();
+ tx.execute(
+ "UPDATE candidate SET state='approved', resolved_at=?1 WHERE id=?2",
+ rusqlite::params![at, candidate_id],
+ )?;
+ tx.execute(
+ "INSERT INTO package (repo_id, release_id, name, arch, version, state)
+ SELECT (SELECT id FROM repo ORDER BY id LIMIT 1), ?1,
+ b.name, 'x86_64', c.pkgver || '-' || c.pkgrel, 'in_index'
+ FROM candidate c JOIN pkgbase b ON b.id = c.pkgbase_id WHERE c.id=?2",
+ rusqlite::params![release_id, candidate_id],
+ )?;
+ tx.execute(
+ "UPDATE pkgbase SET current_accepted_release_id=?1
+ WHERE id=(SELECT pkgbase_id FROM candidate WHERE id=?2)",
+ rusqlite::params![release_id, candidate_id],
+ )?;
+ Ok(release_id)
+ })
+ .unwrap()
+ }
+
pub fn query_i64(&self, sql: &str, params: &[P]) -> Option<i64> {
let sql = sql.to_string();
let params: Vec<P> = params.to_vec();