summaryrefslogtreecommitdiffstats
path: root/tests/pipeline.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pipeline.rs')
-rw-r--r--tests/pipeline.rs77
1 files changed, 22 insertions, 55 deletions
diff --git a/tests/pipeline.rs b/tests/pipeline.rs
index d3816d6..1f62203 100644
--- a/tests/pipeline.rs
+++ b/tests/pipeline.rs
@@ -25,8 +25,7 @@ fn run_for(env: &Env, c: &CandidateRow) -> pipeline::Outcome {
fn in_index(env: &Env) -> Vec<(String, String)> {
env.db
.read(|c| {
- let mut st =
- c.prepare("SELECT name, version FROM package WHERE state='in_index' ORDER BY name")?;
+ let mut st = c.prepare("SELECT name, version FROM package WHERE state='in_index' ORDER BY name")?;
let rows = st.query_map([], |r| Ok((r.get(0)?, r.get(1)?)))?;
let mut v = Vec::new();
for r in rows {
@@ -71,10 +70,7 @@ fn end_to_end_publishes_a_signed_index() {
let all = step_rows(&env);
assert_eq!(all.len(), BUILD_STEPS.len(), "one row per step: {all:?}");
- assert!(
- all.iter().all(|(_, s)| s == "succeeded" || s == "skipped"),
- "{all:?}"
- );
+ assert!(all.iter().all(|(_, s)| s == "succeeded" || s == "skipped"), "{all:?}");
}
#[test]
@@ -116,11 +112,7 @@ fn a_tampered_store_artifact_fails_the_lease_closed() {
let (digest, path): (String, String) = env
.db
- .read(|c| {
- Ok(c.query_row("SELECT digest, path FROM artifact LIMIT 1", [], |r| {
- Ok((r.get(0)?, r.get(1)?))
- })?)
- })
+ .read(|c| Ok(c.query_row("SELECT digest, path FROM artifact LIMIT 1", [], |r| Ok((r.get(0)?, r.get(1)?)))?))
.unwrap();
let original = std::fs::read(&path).unwrap();
let mut tampered = original.clone();
@@ -186,11 +178,9 @@ fn i8_served_index_holds_exactly_the_accepted_pointers() {
let old: i64 = env
.db
.read(|c| {
- Ok(c.query_row(
- "SELECT count(*) FROM package WHERE state='in_index' AND version='1.0-1'",
- [],
- |r| r.get(0),
- )?)
+ Ok(c.query_row("SELECT count(*) FROM package WHERE state='in_index' AND version='1.0-1'", [], |r| {
+ r.get(0)
+ })?)
})
.unwrap();
assert_eq!(old, 0, "the previous release must leave the index");
@@ -200,10 +190,7 @@ fn i8_served_index_holds_exactly_the_accepted_pointers() {
fn step0_fails_closed_when_the_recipe_hash_drifts() {
let (env, _fx) = env_with_fixture("plain-make");
let c = approve_fixture(&env, "plain-make");
- env.exec(
- "UPDATE snapshot SET recipe_hash='deadbeef' WHERE id=?1",
- &params(vec![c.snapshot_id]),
- );
+ env.exec("UPDATE snapshot SET recipe_hash='deadbeef' WHERE id=?1", &params(vec![c.snapshot_id]));
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
match pipeline::run(&env.cfg, &env.db, &id).unwrap() {
pipeline::Outcome::Failed { step, error, .. } => {
@@ -213,7 +200,7 @@ fn step0_fails_closed_when_the_recipe_hash_drifts() {
other => panic!("expected a fail-closed failure, got {other:?}"),
}
assert!(db::accepted_release(&env.db, "plain-make").unwrap().is_none());
- assert!(in_index(&env).is_empty());
+ assert_eq!(in_index(&env), [] as [(std::string::String, std::string::String); 0]);
}
#[test]
@@ -232,7 +219,7 @@ fn step4_fails_closed_when_pkgver_no_longer_matches() {
}
other => panic!("expected a fail-closed pkgver failure, got {other:?}"),
}
- assert!(in_index(&env).is_empty());
+ assert_eq!(in_index(&env), [] as [(std::string::String, std::string::String); 0]);
}
#[test]
@@ -259,10 +246,7 @@ fn i4_kill_mid_publish_leaves_the_old_index_intact() {
assert_eq!(std::fs::read(&v1).unwrap(), before);
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0-1".into())]);
- assert_eq!(
- env.query_i64("SELECT count(*) FROM release WHERE pkgver='1.0.1'", &[]),
- Some(0)
- );
+ assert_eq!(env.query_i64("SELECT count(*) FROM release WHERE pkgver='1.0.1'", &[]), Some(0));
}
#[test]
@@ -275,12 +259,8 @@ fn i5_a_restarted_build_resumes_at_the_next_incomplete_step() {
let c2 = approve_pending(&env, "plain-make");
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c2).unwrap();
env.set_publish_fault("before-rename");
- assert!(matches!(
- pipeline::run(&env.cfg, &env.db, &id).unwrap(),
- pipeline::Outcome::Failed { .. }
- ));
- let builds_after_crash =
- aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makepkg", "");
+ assert!(matches!(pipeline::run(&env.cfg, &env.db, &id).unwrap(), pipeline::Outcome::Failed { .. }));
+ let builds_after_crash = aur_build::shims::called_with(&env.cfg.hooks.shim_dir.clone().unwrap(), "makepkg", "");
assert_eq!(builds_after_crash, 2, "one real build before the crash");
env.clear_publish_fault();
@@ -294,10 +274,7 @@ fn i5_a_restarted_build_resumes_at_the_next_incomplete_step() {
"resuming must not rebuild"
);
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0.1-1".into())]);
- assert_eq!(
- env.query_i64("SELECT count(*) FROM release WHERE pkgver='1.0.1'", &[]),
- Some(1)
- );
+ assert_eq!(env.query_i64("SELECT count(*) FROM release WHERE pkgver='1.0.1'", &[]), Some(1));
}
#[test]
@@ -327,10 +304,7 @@ fn a_failed_build_leaves_the_previous_version_serving() {
other => panic!("{other:?}"),
}
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0-1".into())]);
- assert_eq!(
- candidates::candidate_by_id(&env.db, c2.id).unwrap().unwrap().state,
- CandidateState::Approved
- );
+ assert_eq!(candidates::candidate_by_id(&env.db, c2.id).unwrap().unwrap().state, CandidateState::Approved);
assert_eq!(
env.query_i64("SELECT count(*) FROM package WHERE state='in_index' AND version='1.0.1-1'", &[]),
Some(0)
@@ -385,10 +359,7 @@ fn i6_manual_rebuild_reuses_the_approved_identity() {
let before = env.query_i64("SELECT count(*) FROM approval", &[]);
let id = pipeline::enqueue_manual_rebuild(&env.cfg, &env.db, "plain-make").unwrap();
- assert!(matches!(
- pipeline::run(&env.cfg, &env.db, &id).unwrap(),
- pipeline::Outcome::Succeeded { .. }
- ));
+ assert!(matches!(pipeline::run(&env.cfg, &env.db, &id).unwrap(), pipeline::Outcome::Succeeded { .. }));
assert_eq!(env.query_i64("SELECT count(*) FROM approval", &[]), before);
assert_eq!(in_index(&env), vec![("plain-make".into(), "1.0-1".into())]);
assert_eq!(env.query_i64("SELECT count(*) FROM release", &[]), Some(2));
@@ -424,7 +395,9 @@ fn i12_world_snapshot_is_recorded_at_ingest() {
let json: String = env
.db
.read(|c| {
- Ok(c.query_row("SELECT members_json FROM world_snapshot WHERE id=?1", rusqlite::params![wid], |r| r.get(0))?)
+ Ok(c.query_row("SELECT members_json FROM world_snapshot WHERE id=?1", rusqlite::params![wid], |r| {
+ r.get(0)
+ })?)
})
.unwrap();
let parsed: Vec<serde_json::Value> = serde_json::from_str(&json).unwrap();
@@ -464,10 +437,7 @@ fn a_stale_accepted_pointer_refuses_to_publish() {
let (env, _fx) = env_with_fixture("plain-make");
let c = approve_fixture(&env, "plain-make");
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
- env.exec(
- "UPDATE pkgbase SET current_accepted_release_id=4242 WHERE name='plain-make'",
- &[],
- );
+ env.exec("UPDATE pkgbase SET current_accepted_release_id=4242 WHERE name='plain-make'", &[]);
match pipeline::run(&env.cfg, &env.db, &id).unwrap() {
pipeline::Outcome::Failed { step, error, .. } => {
assert_eq!(step, "publish");
@@ -475,7 +445,7 @@ fn a_stale_accepted_pointer_refuses_to_publish() {
}
other => panic!("expected a CAS refusal, got {other:?}"),
}
- assert!(in_index(&env).is_empty());
+ assert_eq!(in_index(&env), [] as [(std::string::String, std::string::String); 0]);
}
// ------------------------------------------------------- withdrawal and cleanup --
@@ -500,13 +470,10 @@ fn a_publish_that_does_not_land_leaves_no_orphan_files_in_the_served_tree() {
let c = approve_fixture(&env, "plain-make");
env.set_publish_fault("before-rename");
let id = pipeline::enqueue_for_candidate(&env.cfg, &env.db, &c).unwrap();
- assert!(matches!(
- pipeline::run(&env.cfg, &env.db, &id).unwrap(),
- pipeline::Outcome::Failed { .. }
- ));
+ assert!(matches!(pipeline::run(&env.cfg, &env.db, &id).unwrap(), pipeline::Outcome::Failed { .. }));
let stray: Vec<String> = std::fs::read_dir(env.cfg.repo_arch_dir())
.expect("arch dir")
- .filter_map(|e| e.ok())
+ .filter_map(std::result::Result::ok)
.map(|e| e.file_name().to_string_lossy().to_string())
.filter(|n| n.ends_with(".pkg.tar.zst") || n.ends_with(".sig"))
.collect();