summaryrefslogtreecommitdiffstats
path: root/tests/approve.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
commite757979f1a2afdbe7146066345bb9acd19d3b151 (patch)
tree30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /tests/approve.rs
parent94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff)
downloadaur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.tar.gz
aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.zip
comments: say why, not what
Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath.
Diffstat (limited to 'tests/approve.rs')
-rw-r--r--tests/approve.rs37
1 files changed, 13 insertions, 24 deletions
diff --git a/tests/approve.rs b/tests/approve.rs
index f1fc762..86dcf46 100644
--- a/tests/approve.rs
+++ b/tests/approve.rs
@@ -1,9 +1,3 @@
-//! Approval semantics (§7.1, §7.1a, §7.2) and the CLI approval path (P0).
-//!
-//! The rule these tests exist to protect: **we build exactly what was displayed,
-//! or nothing.** An approval that does not match the hashes of what the reviewer
-//! was shown is refused, never retargeted.
-
mod common;
use aur_build::db::model::*;
@@ -111,13 +105,12 @@ fn approving_twice_is_refused_not_duplicated() {
fn a_broken_database_is_not_reported_as_a_stale_review() {
// What this pins: every failure inside the approval transaction used to be
// mapped into `Stale::NotPending`, so a SQLite error reached the reviewer as
- // "review is no longer pending (state: sqlite: …)" — the one message that
- // tells them to look again when the truth is that the write failed (§6 M-3).
+ // "review is no longer pending" — the one message telling them to look again
+ // when the truth is that the write failed (§6 M-3).
let (env, _fx) = env_with_fixture("plain-make");
let (c, dd) = open_review(&env, "plain-make");
- // Make the write impossible halfway through the transaction: the approval
- // row and the candidate update succeed, then the audit append has nowhere
- // to go.
+ // Make the write impossible halfway through: the approval row and the
+ // candidate update succeed, then the audit append has nowhere to go.
env.exec("DROP TABLE audit", &[]);
let err = approve(&env.db, "tester", c.id, &c.identity_hash, &dd, None).unwrap_err();
assert!(matches!(err, ApproveError::System(_)), "a broken database was reported as a stale review: {err:?}");
@@ -131,8 +124,7 @@ fn a_broken_database_is_not_reported_as_a_stale_review() {
#[test]
fn bulk_refusals_are_their_own_reasons() {
// Bulk used to bend `Stale::NotPending` into "high risk", "unknown decision"
- // and "the database failed", and to hand back a fabricated `Approval { id: 0 }`
- // for a rejection that recorded no approval at all (§6 M-3).
+ // and "the database failed" (§6 M-3).
let (env, _fx) = env_with_fixture("plain-make");
let (c, dd) = open_review(&env, "plain-make");
candidates::set_risk(&env.db, c.id, "high", &["new source host".into()]).unwrap();
@@ -168,8 +160,7 @@ fn a_bulk_rejection_hands_back_no_invented_approval() {
let (c, dd) = open_review(&env, "plain-make");
let out = bulk(&env.db, "tester", &[(c.id, c.identity_hash.clone(), dd)], "reject", &[]).unwrap();
assert!(matches!(out[0].outcome, BulkOutcome::Rejected), "{:?}", out[0].outcome);
- // A rejection records a `rejected` row; there is no approval to return, and
- // the old `Approval { id: 0 }` sentinel is gone.
+ // A rejection records a `rejected` row; there is no approval to return.
assert_eq!(env.query_i64("SELECT count(*) FROM approval WHERE decision='rejected'", &[]), Some(1));
assert_eq!(env.query_i64("SELECT count(*) FROM approval WHERE decision='approved'", &[]), Some(0));
}
@@ -209,8 +200,8 @@ fn once_viewed_a_new_state_freezes_the_old_one_as_superseded() {
assert_ne!(open[0].id, c.id, "a fresh review was opened");
let frozen = candidates::candidate_by_id(&env.db, c.id).unwrap().unwrap();
assert_eq!(frozen.state, CandidateState::Superseded);
- // The frozen one can no longer be approved: approving it would build a
- // version nobody is looking at.
+ // The frozen one can no longer be approved: approving it would build a version
+ // nobody is looking at.
let err = approve(&env.db, "tester", c.id, &frozen.identity_hash, &frozen.diff_digest, None).unwrap_err();
assert!(matches!(err, ApproveError::Stale(Stale::NotPending { .. })), "{err:?}");
}
@@ -246,9 +237,7 @@ fn reject_requires_a_reason_and_records_it() {
.unwrap();
assert!(note.contains("license"), "{note}");
- // And the audit row says *which review* was rejected, not only why (§6 m-4):
- // the three review actions each hand-built their own `detail`, and two of
- // them recorded no identity at all.
+ // And the audit row says *which review* was rejected, not only why (§6 m-4).
let (actor_kind, detail): (String, String) = env
.db
.read(|c| {
@@ -268,8 +257,8 @@ fn reject_requires_a_reason_and_records_it() {
// ------------------------------------------------------------- the CLI path --
-/// Drive the real binary the way an operator would. This is the P0 approval
-/// path: `init`, `subscribe`, `detect`, `show`, `approve --yes`.
+/// Drive the real binary the way an operator would: `init`, `subscribe`,
+/// `detect`, `show`, `approve --yes`.
#[test]
fn cli_end_to_end_approves_and_queues_a_build() {
let tmp = tempfile::tempdir().unwrap();
@@ -291,8 +280,8 @@ fn cli_end_to_end_approves_and_queues_a_build() {
let out = cli(bin, &root, &["reviews"]);
assert!(out.stdout.contains("#1"), "reviews: {}", out.stdout);
- // `show` renders the panels and the hashes; `approve` without --yes refuses
- // to act, which is the CLI's version of "look before you approve".
+ // `show` renders the panels and the hashes; `approve` without --yes refuses to
+ // act.
let out = cli(bin, &root, &["show", "1"]);
assert!(out.stdout.contains("identity_hash"), "show: {}", out.stdout);
let shown = out.stdout.clone();