summaryrefslogtreecommitdiffstats
path: root/tests/approve.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
committeraur-build <aur-build@localhost>2026-11-22 10:36:24 +0000
commit3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch)
tree7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /tests/approve.rs
parent9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff)
downloadaur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.tar.gz
aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.zip
rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off
rustfmt.toml fixes the shape the tree is written in (120 columns, small items kept on one line) and one canonical pass makes it the truth. [lints.clippy] names the idiom lints worth enforcing and leaves out the two that would add doc-comment boilerplate rather than remove it. The tree pays them off here: write!/writeln! instead of push_str(&format!()), let-else instead of match-on-Option, borrows where a thread entry point only reads what it owns, no `&self` on a Copy state and no `self` nobody reads. ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and value are now emitted by the same call instead of three.
Diffstat (limited to 'tests/approve.rs')
-rw-r--r--tests/approve.rs47
1 files changed, 12 insertions, 35 deletions
diff --git a/tests/approve.rs b/tests/approve.rs
index c5be8e0..97423b3 100644
--- a/tests/approve.rs
+++ b/tests/approve.rs
@@ -45,7 +45,7 @@ fn approve_writes_an_immutable_row_carrying_both_hashes() {
.read(|c| {
let mut st = c.prepare("SELECT action FROM audit ORDER BY id")?;
let rows = st.query_map([], |r| r.get::<_, String>(0))?;
- Ok(rows.filter_map(|r| r.ok()).collect())
+ Ok(rows.filter_map(std::result::Result::ok).collect())
})
.unwrap();
assert!(actions.iter().any(|a| a == "approve"), "{actions:?}");
@@ -115,17 +115,9 @@ fn bulk_refusals_are_their_own_reasons() {
let items = [(c.id, c.identity_hash.clone(), dd.clone())];
let out = bulk(&env.db, "tester", &items, "approve", &[]).unwrap();
- assert!(
- matches!(out[0].outcome, BulkOutcome::Refused(BulkRefusal::HighRiskUnconfirmed)),
- "{:?}",
- out[0].outcome
- );
+ assert!(matches!(out[0].outcome, BulkOutcome::Refused(BulkRefusal::HighRiskUnconfirmed)), "{:?}", out[0].outcome);
let out = bulk(&env.db, "tester", &items, "ship-it", &[]).unwrap();
- assert!(
- matches!(out[0].outcome, BulkOutcome::Refused(BulkRefusal::UnknownDecision(_))),
- "{:?}",
- out[0].outcome
- );
+ assert!(matches!(out[0].outcome, BulkOutcome::Refused(BulkRefusal::UnknownDecision(_))), "{:?}", out[0].outcome);
let out = bulk(&env.db, "tester", &items, "approve", &[c.id]).unwrap();
assert!(matches!(out[0].outcome, BulkOutcome::Approved(_)), "{:?}", out[0].outcome);
let out = bulk(&env.db, "tester", &items, "approve", &[c.id]).unwrap();
@@ -200,11 +192,7 @@ fn reject_requires_a_reason_and_records_it() {
let note: String = env
.db
.read(|c| {
- Ok(c.query_row(
- "SELECT note FROM approval WHERE candidate_id=?1",
- rusqlite::params![cid],
- |r| r.get(0),
- )?)
+ Ok(c.query_row("SELECT note FROM approval WHERE candidate_id=?1", rusqlite::params![cid], |r| r.get(0))?)
})
.unwrap();
assert!(note.contains("license"), "{note}");
@@ -220,10 +208,7 @@ fn reject_requires_a_reason_and_records_it() {
})
.unwrap();
assert_eq!(actor_kind, "human");
- assert!(
- detail.contains(&c.identity_hash),
- "the audit row does not say which review bytes were rejected: {detail}"
- );
+ assert!(detail.contains(&c.identity_hash), "the audit row does not say which review bytes were rejected: {detail}");
}
// ------------------------------------------------------------- the CLI path --
@@ -266,7 +251,7 @@ fn cli_end_to_end_approves_and_queues_a_build() {
assert!(shown.contains("PKGBUILD") || shown.contains("pkgver"), "diff pane: {shown}");
let out = cli(bin, &root, &["approve", "1", "--yes"]);
- assert_eq!(out.code, Some(2), "stale approval should exit 2: {:?}", out);
+ assert_eq!(out.code, Some(2), "stale approval should exit 2: {out:?}");
}
#[test]
@@ -280,7 +265,7 @@ fn cli_approve_refuses_a_hash_that_was_never_shown() {
cli(bin, &root, &["subscribe", "plain-make", "--url", &url]);
cli(bin, &root, &["detect", "plain-make"]);
let out = cli(bin, &root, &["approve", "1", "--yes", "--identity", "sha256:invented", "--diff", "sha256:invented"]);
- assert_eq!(out.code, Some(2), "must refuse: {:?}", out);
+ assert_eq!(out.code, Some(2), "must refuse: {out:?}");
assert!(out.stderr.contains("refused"), "stderr: {}", out.stderr);
assert_eq!(cli_count(&root, "approval"), 0);
}
@@ -294,12 +279,7 @@ struct Out {
}
fn cli(bin: &str, root: &std::path::Path, args: &[&str]) -> Out {
- let out = std::process::Command::new(bin)
- .arg("--root")
- .arg(root)
- .args(args)
- .output()
- .expect("run aur-build");
+ let out = std::process::Command::new(bin).arg("--root").arg(root).args(args).output().expect("run aur-build");
Out {
code: out.status.code(),
status: out.status,
@@ -314,11 +294,8 @@ fn cli_fixture(root: &std::path::Path, name: &str) -> (std::path::PathBuf, Fixtu
}
fn cli_count(root: &std::path::Path, table: &str) -> i64 {
- let conn = rusqlite::Connection::open_with_flags(
- root.join("aur-build.db"),
- rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY,
- )
- .expect("open cli db");
- conn.query_row(&format!("SELECT count(*) FROM {table}"), [], |r| r.get::<_, i64>(0))
- .unwrap()
+ let conn =
+ rusqlite::Connection::open_with_flags(root.join("aur-build.db"), rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY)
+ .expect("open cli db");
+ conn.query_row(&format!("SELECT count(*) FROM {table}"), [], |r| r.get::<_, i64>(0)).unwrap()
}