summaryrefslogtreecommitdiffstats
path: root/tests/approve.rs
diff options
context:
space:
mode:
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()
}