diff options
| author | aur-build <aur-build@localhost> | 2026-11-22 10:36:24 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-22 10:36:24 +0000 |
| commit | 3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch) | |
| tree | 7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /tests/detect.rs | |
| parent | 9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff) | |
| download | aur-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/detect.rs')
| -rw-r--r-- | tests/detect.rs | 53 |
1 files changed, 8 insertions, 45 deletions
diff --git a/tests/detect.rs b/tests/detect.rs index 7edc529..0a87231 100644 --- a/tests/detect.rs +++ b/tests/detect.rs @@ -17,10 +17,7 @@ fn seed(env: &Env, name: &str, pkgver: &str, pkgrel: &str, extra: &str) -> Strin fn pending(env: &Env, name: &str) -> Option<CandidateRow> { let pb = db::get_pkgbase(&env.db, name).unwrap().unwrap(); - candidates::pending_candidates(&env.db) - .unwrap() - .into_iter() - .find(|c| c.pkgbase_id == pb.id) + candidates::pending_candidates(&env.db).unwrap().into_iter().find(|c| c.pkgbase_id == pb.id) } fn accepted(env: &Env, name: &str) -> Option<ReleaseRow> { @@ -100,13 +97,7 @@ fn skip_sources_are_stream_hashed_into_the_cache() { let payload = env.path("payload.txt"); std::fs::write(&payload, b"the bytes that become the package").unwrap(); let expected = aur_build::hash::hex(b"the bytes that become the package"); - seed( - &env, - "foo", - "1.0", - "1", - &format!("source=(file://{})\nsha256sums=('SKIP')\n", payload.display()), - ); + seed(&env, "foo", "1.0", "1", &format!("source=(file://{})\nsha256sums=('SKIP')\n", payload.display())); check_pkgbase(&env.cfg, &env.db, "foo").unwrap(); let c = pending(&env, "foo").unwrap(); let digests = c.digests(); @@ -130,13 +121,7 @@ fn declared_checksums_are_trusted_without_downloading() { let payload = env.path("declared.txt"); std::fs::write(&payload, b"verified bytes").unwrap(); let d = aur_build::hash::hex(b"verified bytes"); - seed( - &env, - "foo", - "1.0", - "1", - &format!("source=(file://{})\nsha256sums=('{d}')\n", payload.display()), - ); + seed(&env, "foo", "1.0", "1", &format!("source=(file://{})\nsha256sums=('{d}')\n", payload.display())); check_pkgbase(&env.cfg, &env.db, "foo").unwrap(); let c = pending(&env, "foo").unwrap(); assert_eq!(c.digests()[0].digest, d); @@ -173,10 +158,7 @@ fn i2_diff_base_is_the_last_accepted_version_however_many_detections_arrive() { assert_eq!(c.revision, 2, "revision counts the collapsed detections (v3, v4)"); assert_eq!(c.base_release_id, Some(rel1), "base never moves: the diff is v1 -> v4"); assert_eq!(c.version(), "4.0-1"); - assert_eq!( - env.query_i64("SELECT count(*) FROM candidate WHERE state='pending_review'", &[]), - Some(1) - ); + assert_eq!(env.query_i64("SELECT count(*) FROM candidate WHERE state='pending_review'", &[]), Some(1)); } #[test] @@ -207,13 +189,7 @@ fn a_viewed_review_is_frozen_and_a_fresh_one_opened() { assert_eq!(c3.version(), "3.0-1"); let old_state: String = env .db - .read(|c| { - Ok(c.query_row( - "SELECT state FROM candidate WHERE id=?1", - rusqlite::params![c2.id], - |r| r.get(0), - )?) - }) + .read(|c| Ok(c.query_row("SELECT state FROM candidate WHERE id=?1", rusqlite::params![c2.id], |r| r.get(0))?)) .unwrap(); assert_eq!( CandidateState::parse(&old_state), @@ -231,11 +207,7 @@ fn a_rejected_identity_is_not_re_raised() { let c = pending(&env, "foo").unwrap(); approve::reject(&env.db, "tester", c.id, "not this one").unwrap(); let rep = check_pkgbase(&env.cfg, &env.db, "foo").unwrap(); - assert!( - matches!(rep.outcome, Outcome::PreviouslyRejected | Outcome::NoChange), - "{:?}", - rep.outcome - ); + assert!(matches!(rep.outcome, Outcome::PreviouslyRejected | Outcome::NoChange), "{:?}", rep.outcome); assert!(pending(&env, "foo").is_none()); git_add_commit(&aur(&env, "foo"), &[("PKGBUILD", &common::pkgbuild("foo", "2.0", "1", ""))], "v2"); check_pkgbase(&env.cfg, &env.db, "foo").unwrap(); @@ -274,13 +246,7 @@ fn digest_drift_with_an_unchanged_version_is_an_integrity_alert() { env.subscribe("foo"); let payload = env.path("payload.txt"); std::fs::write(&payload, b"good release tarball").unwrap(); - seed( - &env, - "foo", - "1.0", - "1", - &format!("source=(file://{})\nsha256sums=('SKIP')\n", payload.display()), - ); + seed(&env, "foo", "1.0", "1", &format!("source=(file://{})\nsha256sums=('SKIP')\n", payload.display())); check_pkgbase(&env.cfg, &env.db, "foo").unwrap(); let c = pending(&env, "foo").unwrap(); env.accept_as_release(c.id); @@ -309,10 +275,7 @@ fn a_deleted_upstream_marks_the_subscription_and_alerts() { assert!(matches!(rep.outcome, Outcome::Gone), "{:?}", rep.outcome); let sub = db::get_subscription(&env.db, "foo").unwrap().unwrap(); assert_eq!(sub.state, SubscriptionState::Orphaned); - assert!(db::list_notices(&env.db, false) - .unwrap() - .iter() - .any(|n| n.kind == notice_kind::DELETED)); + assert!(db::list_notices(&env.db, false).unwrap().iter().any(|n| n.kind == notice_kind::DELETED)); } #[test] |
