forge
Explore
Log in

Don't you dare go Hollow

Junction-era test pins and homework audience recheck

Browse files at this commit

fa1529a905be335e22ed09e281ad5f45df9450a3Ahmet Kaan GümüşParent: 5ff42c5
  • fix
    • junction-era test pins and homework audience recheck
Show full message
🐛 fix: junction-era test pins and homework audience recheck

class_course.source and board_participant are uuids, not grade text /
participants[]. Submission upsert locks homework then re-reads
assignment, so a narrowing PATCH cannot land a 201 for a dropped student.

Local: cargo nextest run --no-fail-fast → 1373 passed.
.sqlx/query-3490bf0f42b3e2c64443add6058b32451c0d228cc05490df6c64e245f453a6d7.jsonadded+24 -0
@@ -0,0 +1,24 @@
1+{
2+ "db_name": "PostgreSQL",
3+ "query": "SELECT (NOT EXISTS (\n SELECT 1 FROM homework_assignment a WHERE a.homework = $1)\n OR EXISTS (\n SELECT 1 FROM homework_assignment a\n WHERE a.homework = $1 AND a.student = $2)) AS \"named!\"",
4+ "describe": {
5+ "columns": [
6+ {
7+ "ordinal": 0,
8+ "name": "named!",
9+ "type_info": "Bool",
10+ "origin": "Expression"
11+ }
12+ ],
13+ "parameters": {
14+ "Left": [
15+ "Uuid",
16+ "Uuid"
17+ ]
18+ },
19+ "nullable": [
20+ null
21+ ]
22+ },
23+ "hash": "3490bf0f42b3e2c64443add6058b32451c0d228cc05490df6c64e245f453a6d7"
24+}
.sqlx/query-c3232a6de8535065f4fc7e1a19494dd17acb47f65cca634b739f9ff6cd0a6894.json → .sqlx/query-9bb1a80e986bf6126b5d34d03027a50688cc8fafd1d56ffba546dd2360eb01d3.jsonrenamed+2 -3
@@ -1,6 +1,6 @@
1 {1 {
2 "db_name": "PostgreSQL",2 "db_name": "PostgreSQL",
3- "query": "SELECT due_at AS \"due_at: Timestamp\" FROM homework\n WHERE id = $1\n AND (NOT EXISTS (SELECT 1 FROM homework_assignment a\n WHERE a.homework = homework.id)\n OR EXISTS (SELECT 1 FROM homework_assignment a\n WHERE a.homework = homework.id AND a.student = $2))\n FOR UPDATE",3+ "query": "SELECT due_at AS \"due_at: Timestamp\" FROM homework\n WHERE id = $1 FOR UPDATE",
4 "describe": {4 "describe": {
5 "columns": [5 "columns": [
6 {6 {
@@ -17,7 +17,6 @@
17 ],17 ],
18 "parameters": {18 "parameters": {
19 "Left": [19 "Left": [
20- "Uuid",
21 "Uuid"20 "Uuid"
22 ]21 ]
23 },22 },
@@ -25,5 +24,5 @@
25 false24 false
26 ]25 ]
27 },26 },
28- "hash": "c3232a6de8535065f4fc7e1a19494dd17acb47f65cca634b739f9ff6cd0a6894"27+ "hash": "9bb1a80e986bf6126b5d34d03027a50688cc8fafd1d56ffba546dd2360eb01d3"
29 }28 }
src/db/homework_submission.rsmodified+22 -15
@@ -73,25 +73,32 @@ pub async fn upsert(
73 // submission goes through its homework). `Err(NotFound)` means the73 // submission goes through its homework). `Err(NotFound)` means the
74 // homework is gone, which is the 404 the web layer's own lookup74 // homework is gone, which is the 404 the web layer's own lookup
75 // would have answered.75 // would have answered.
76- let was_due = sqlx::query!(76+ let due = sqlx::query!(
77- // The audience re-checks UNDER the lock: a narrowing PATCH commits
78- // between the web layer's pre-flight read and this write, and a
79- // student the homework no longer names must read as gone — the
80- // same 404 their own lookup answers.
81 r#"SELECT due_at AS "due_at: Timestamp" FROM homework77 r#"SELECT due_at AS "due_at: Timestamp" FROM homework
82- WHERE id = $178+ WHERE id = $1 FOR UPDATE"#,
83- AND (NOT EXISTS (SELECT 1 FROM homework_assignment a
84- WHERE a.homework = homework.id)
85- OR EXISTS (SELECT 1 FROM homework_assignment a
86- WHERE a.homework = homework.id AND a.student = $2))
87- FOR UPDATE"#,
88 homework_id.uuid(),79 homework_id.uuid(),
89- user.uuid()
90 )80 )
91 .fetch_optional(&mut *tx)81 .fetch_optional(&mut *tx)
92- .await?82+ .await?;
93- .map(|row| row.due_at);83+ let Some(due) = due else {
94- let Some(was_due) = was_due else {84+ return Err(AppError::NotFound);
85+ };
86+ let was_due = due.due_at;
87+ // Re-read the audience after the lock: a narrowing PATCH that held
88+ // this row may have committed while we waited, and SELECT FOR UPDATE
89+ // does not re-evaluate a subquery on another table.
90+ let named: bool = sqlx::query_scalar!(
91+ r#"SELECT (NOT EXISTS (
92+ SELECT 1 FROM homework_assignment a WHERE a.homework = $1)
93+ OR EXISTS (
94+ SELECT 1 FROM homework_assignment a
95+ WHERE a.homework = $1 AND a.student = $2)) AS "named!""#,
96+ homework_id.uuid(),
97+ user.uuid(),
98+ )
99+ .fetch_one(&mut *tx)
100+ .await?;
101+ if !named {
95 return Err(AppError::NotFound);102 return Err(AppError::NotFound);
96 };103 };
97 // Equal counts as on time, exactly as the deadline has always been104 // Equal counts as on time, exactly as the deadline has always been
tests/regress_blueprints.rsmodified+41 -42
@@ -57,11 +57,11 @@ async fn attached(class: &str, course: &str, db: &Database) -> bool {
57 == 157 == 1
58 }58 }
59 59
60-/// The blueprint key stored on one attachment, or `None` when the row carries60+/// The blueprint id stored on one attachment, or `None` when the row carries
61 /// no such key at all — which is the whole provenance rule: absent means a61 /// no such key at all — which is the whole provenance rule: absent means a
62 /// human attached it.62 /// human attached it.
63-async fn source_of(class: &str, course: &str, db: &Database) -> Option<String> {63+async fn source_of(class: &str, course: &str, db: &Database) -> Option<uuid::Uuid> {
64- sqlx::query_scalar::<_, Option<String>>(64+ sqlx::query_scalar::<_, Option<uuid::Uuid>>(
65 "SELECT source FROM class_course WHERE class = $1 AND course = $2",65 "SELECT source FROM class_course WHERE class = $1 AND course = $2",
66 )66 )
67 .bind(uuid::Uuid::parse_str(class).expect("a uuid class id"))67 .bind(uuid::Uuid::parse_str(class).expect("a uuid class id"))
@@ -71,6 +71,14 @@ async fn source_of(class: &str, course: &str, db: &Database) -> Option<String> {
71 .unwrap()71 .unwrap()
72 }72 }
73 73
74+async fn blueprint_id(grade: &str, db: &Database) -> uuid::Uuid {
75+ sqlx::query_scalar::<_, uuid::Uuid>("SELECT id FROM class_blueprint WHERE grade = $1")
76+ .bind(grade)
77+ .fetch_one(db)
78+ .await
79+ .unwrap()
80+}
81+
74 /// Does that grade's template still name that course, in the store?82 /// Does that grade's template still name that course, in the store?
75 async fn templated(grade: &str, course: &str, db: &Database) -> bool {83 async fn templated(grade: &str, course: &str, db: &Database) -> bool {
76 sqlx::query_scalar::<_, i64>(84 sqlx::query_scalar::<_, i64>(
@@ -306,7 +314,7 @@ async fn a_fresh_class_takes_its_grades_blueprint() {
306 assert!(attached(&class, course, &db).await);314 assert!(attached(&class, course, &db).await);
307 assert_eq!(315 assert_eq!(
308 source_of(&class, course, &db).await,316 source_of(&class, course, &db).await,
309- Some("9".to_string()),317+ Some(blueprint_id("9", &db).await),
310 "the blueprint must own what it attached"318 "the blueprint must own what it attached"
311 );319 );
312 assert_eq!(320 assert_eq!(
@@ -323,8 +331,7 @@ async fn a_fresh_class_takes_its_grades_blueprint() {
323 );331 );
324 }332 }
325 assert_eq!(333 assert_eq!(
326- count_on("class_course_count", "class_group", &class, &db)334+ count_on("class_course_count", "class_group", &class, &db).await,
327- .await,
328 2335 2
329 );336 );
330 337
@@ -400,13 +407,12 @@ async fn creating_a_class_stocks_it_from_its_grades_blueprint() {
400 assert!(attached(&class, course, &db).await, "{course} is attached");407 assert!(attached(&class, course, &db).await, "{course} is attached");
401 assert_eq!(408 assert_eq!(
402 source_of(&class, course, &db).await,409 source_of(&class, course, &db).await,
403- Some("9".to_string()),410+ Some(blueprint_id("9", &db).await),
404 "the blueprint must own what a create attached, exactly as a pump does"411 "the blueprint must own what a create attached, exactly as a pump does"
405 );412 );
406 }413 }
407 assert_eq!(414 assert_eq!(
408- count_on("class_course_count", "class_group", &class, &db)415+ count_on("class_course_count", "class_group", &class, &db).await,
409- .await,
410 2416 2
411 );417 );
412 418
@@ -445,13 +451,11 @@ async fn creating_a_class_stocks_it_from_its_grades_blueprint() {
445 assert!(skips(&res).is_empty(), "{:?}", res.body);451 assert!(skips(&res).is_empty(), "{:?}", res.body);
446 let bare = res.body["class"]["id"].as_str().unwrap();452 let bare = res.body["class"]["id"].as_str().unwrap();
447 assert_eq!(453 assert_eq!(
448- sqlx::query_scalar::<_, i64>(454+ sqlx::query_scalar::<_, i64>("SELECT count(*) FROM class_course WHERE class = $1",)
449- "SELECT count(*) FROM class_course WHERE class = $1",455+ .bind(uuid::Uuid::parse_str(bare).expect("a uuid class id"))
450- )456+ .fetch_one(&db)
451- .bind(uuid::Uuid::parse_str(bare).expect("a uuid class id"))457+ .await
452- .fetch_one(&db)458+ .unwrap(),
453- .await
454- .unwrap(),
455 0,459 0,
456 "nothing may be attached to a section no template reached"460 "nothing may be attached to a section no template reached"
457 );461 );
@@ -608,19 +612,16 @@ async fn an_edit_retro_pumps_every_class_at_the_grade() {
608 // grade.612 // grade.
609 for class in [&a, &b] {613 for class in [&a, &b] {
610 assert_eq!(614 assert_eq!(
611- count_on("class_course_count", "class_group", class, &db)615+ count_on("class_course_count", "class_group", class, &db).await,
612- .await,
613 1616 1
614 );617 );
615 }618 }
616 assert_eq!(619 assert_eq!(
617- count_on("class_course_count", "class_group", &ten, &db)620+ count_on("class_course_count", "class_group", &ten, &db).await,
618- .await,
619 0621 0
620 );622 );
621 assert_eq!(623 assert_eq!(
622- count_on("enrollment_count", "course", &algebra, &db)624+ count_on("enrollment_count", "course", &algebra, &db).await,
623- .await,
624 1,625 1,
625 "one student at the grade, one seat"626 "one student at the grade, one seat"
626 );627 );
@@ -681,13 +682,11 @@ async fn a_class_that_does_not_fit_is_reported_not_aborted() {
681 // Nothing moved on the skipped class: not its attachment counter, and not682 // Nothing moved on the skipped class: not its attachment counter, and not
682 // one of the seats the refused attach touched on its way to the refusal.683 // one of the seats the refused attach touched on its way to the refusal.
683 assert_eq!(684 assert_eq!(
684- count_on("class_course_count", "class_group", &full, &db)685+ count_on("class_course_count", "class_group", &full, &db).await,
685- .await,
686 0686 0
687 );687 );
688 assert_eq!(688 assert_eq!(
689- count_on("enrollment_count", "course", &tight, &db)689+ count_on("enrollment_count", "course", &tight, &db).await,
690- .await,
691 0,690 0,
692 "the empty class took no seat, and the refused one gave every seat back"691 "the empty class took no seat, and the refused one gave every seat back"
693 );692 );
@@ -814,7 +813,10 @@ async fn a_removal_spares_a_hand_attached_course() {
814 None,813 None,
815 "a pump may not adopt an attachment it did not make"814 "a pump may not adopt an attachment it did not make"
816 );815 );
817- assert_eq!(source_of(&pumped, &algebra, &db).await, Some("9".into()));816+ assert_eq!(
817+ source_of(&pumped, &algebra, &db).await,
818+ Some(blueprint_id("9", &db).await),
819+ );
818 820
819 // Drop it from the template.821 // Drop it from the template.
820 let patched = send(822 let patched = send(
@@ -836,14 +838,12 @@ async fn a_removal_spares_a_hand_attached_course() {
836 "…and nothing else — a hand attach survives"838 "…and nothing else — a hand attach survives"
837 );839 );
838 assert_eq!(840 assert_eq!(
839- count_on("class_course_count", "class_group", &pumped, &db)841+ count_on("class_course_count", "class_group", &pumped, &db).await,
840- .await,
841 0,842 0,
842 "the detach gives the class its count back"843 "the detach gives the class its count back"
843 );844 );
844 assert_eq!(845 assert_eq!(
845- count_on("class_course_count", "class_group", &byhand, &db)846+ count_on("class_course_count", "class_group", &byhand, &db).await,
846- .await,
847 1847 1
848 );848 );
849 assert_eq!(849 assert_eq!(
@@ -856,8 +856,7 @@ async fn a_removal_spares_a_hand_attached_course() {
856 "the enrollments the blueprint pumped go with it"856 "the enrollments the blueprint pumped go with it"
857 );857 );
858 assert_eq!(858 assert_eq!(
859- count_on("enrollment_count", "course", &algebra, &db)859+ count_on("enrollment_count", "course", &algebra, &db).await,
860- .await,
861 1,860 1,
862 "the hand-attached class keeps its student's seat"861 "the hand-attached class keeps its student's seat"
863 );862 );
@@ -939,8 +938,7 @@ async fn a_row_written_before_the_column_reads_as_hand_attached() {
939 "a pre-migration row is hand-attached and unreachable by any blueprint sweep"938 "a pre-migration row is hand-attached and unreachable by any blueprint sweep"
940 );939 );
941 assert_eq!(940 assert_eq!(
942- count_on("enrollment_count", "course", &algebra, &db)941+ count_on("enrollment_count", "course", &algebra, &db).await,
943- .await,
944 1942 1
945 );943 );
946 }944 }
@@ -996,8 +994,10 @@ async fn a_blueprint_lost_mid_attach_strands_a_row_that_stays_detachable() {
996 // The stranded state: the link row committed, the blueprint it names did994 // The stranded state: the link row committed, the blueprint it names did
997 // not survive. Real FKs refuse that state, so it is written with FK995 // not survive. Real FKs refuse that state, so it is written with FK
998 // triggers suspended — the manager id is real, the `source` FK is the one996 // triggers suspended — the manager id is real, the `source` FK is the one
999- // the strand consists of.997+ // the strand consists of. Capture the uuid before the delete: the grade
998+ // label is UNIQUE, not the FK.
1000 let manager_id = UserId::from_key(&me_id(&app, &manager).await);999 let manager_id = UserId::from_key(&me_id(&app, &manager).await);
1000+ let stranded = blueprint_id("9", &db).await;
1001 let mut tx = db.begin().await.unwrap();1001 let mut tx = db.begin().await.unwrap();
1002 sqlx::query("SET LOCAL session_replication_role = replica")1002 sqlx::query("SET LOCAL session_replication_role = replica")
1003 .execute(&mut *tx)1003 .execute(&mut *tx)
@@ -1009,12 +1009,13 @@ async fn a_blueprint_lost_mid_attach_strands_a_row_that_stays_detachable() {
1009 .unwrap();1009 .unwrap();
1010 sqlx::query(1010 sqlx::query(
1011 "INSERT INTO class_course (class, course, attached_by, attached_at, source) \1011 "INSERT INTO class_course (class, course, attached_by, attached_at, source) \
1012- VALUES ($1, $2, $3, $4, '9')",1012+ VALUES ($1, $2, $3, $4, $5)",
1013 )1013 )
1014 .bind(uuid::Uuid::parse_str(&class).expect("a uuid class id"))1014 .bind(uuid::Uuid::parse_str(&class).expect("a uuid class id"))
1015 .bind(CourseId::from_key(&algebra))1015 .bind(CourseId::from_key(&algebra))
1016 .bind(manager_id)1016 .bind(manager_id)
1017 .bind(Timestamp::now().as_millis())1017 .bind(Timestamp::now().as_millis())
1018+ .bind(stranded)
1018 .execute(&mut *tx)1019 .execute(&mut *tx)
1019 .await1020 .await
1020 .unwrap();1021 .unwrap();
@@ -1035,7 +1036,7 @@ async fn a_blueprint_lost_mid_attach_strands_a_row_that_stays_detachable() {
1035 "the link stands after its blueprint was gone: this is the stranded \1036 "the link stands after its blueprint was gone: this is the stranded \
1036 row, tagged with a record no sweep can ever reach"1037 row, tagged with a record no sweep can ever reach"
1037 );1038 );
1038- assert_eq!(source_of(&class, &algebra, &db).await, Some("9".into()));1039+ assert_eq!(source_of(&class, &algebra, &db).await, Some(stranded));
1039 1040
1040 // The documented recovery: a human detaches it one course at a time, and1041 // The documented recovery: a human detaches it one course at a time, and
1041 // the counters come back exact.1042 // the counters come back exact.
@@ -1055,8 +1056,7 @@ async fn a_blueprint_lost_mid_attach_strands_a_row_that_stays_detachable() {
1055 );1056 );
1056 assert!(!attached(&class, &algebra, &db).await);1057 assert!(!attached(&class, &algebra, &db).await);
1057 assert_eq!(1058 assert_eq!(
1058- count_on("class_course_count", "class_group", &class, &db)1059+ count_on("class_course_count", "class_group", &class, &db).await,
1059- .await,
1060 0,1060 0,
1061 "a stranded row still releases its counter when it is detached"1061 "a stranded row still releases its counter when it is detached"
1062 );1062 );
@@ -1479,8 +1479,7 @@ async fn a_half_swept_removal_is_finished_by_the_documented_re_patch() {
1479 "…enrollments and all"1479 "…enrollments and all"
1480 );1480 );
1481 assert_eq!(1481 assert_eq!(
1482- count_on("enrollment_count", "course", &history, &db)1482+ count_on("enrollment_count", "course", &history, &db).await,
1483- .await,
1484 0,1483 0,
1485 "…with the seat given back"1484 "…with the seat given back"
1486 );1485 );
tests/regress_classes.rsmodified+1 -1
@@ -1592,7 +1592,7 @@ async fn a_course_assignment_whose_teacher_is_demoted_mid_write_is_undone() {
1592 let teacher_id = me_id(&app, &teacher).await;1592 let teacher_id = me_id(&app, &teacher).await;
1593 let course = create_course(&app, &manager, "algebra").await;1593 let course = create_course(&app, &manager, "algebra").await;
1594 1594
1595- demote_during_writes_to("course", "UPDATE", &teacher_id, &db).await;1595+ demote_during_writes_to("course_teacher", "CREATE", &teacher_id, &db).await;
1596 let res = send(1596 let res = send(
1597 &app,1597 &app,
1598 "POST",1598 "POST",
tests/regress_roles.rsmodified+53 -13
@@ -98,7 +98,11 @@ async fn a_demotion_frees_the_event_seat_nothing_else_could_free() {
98 let res = seat(&app, &teacher, &event, &ali_id).await;98 let res = seat(&app, &teacher, &event, &ali_id).await;
99 assert_eq!(res.status, StatusCode::OK, "{}", res.body);99 assert_eq!(res.status, StatusCode::OK, "{}", res.body);
100 assert_eq!(100 assert_eq!(
101- counter("SELECT COALESCE(sum(registration_count), 0)::bigint FROM event", &db).await,101+ counter(
102+ "SELECT COALESCE(sum(registration_count), 0)::bigint FROM event",
103+ &db
104+ )
105+ .await,
102 1106 1
103 );107 );
104 108
@@ -120,7 +124,11 @@ async fn a_demotion_frees_the_event_seat_nothing_else_could_free() {
120 "a non-student may hold no signup row"124 "a non-student may hold no signup row"
121 );125 );
122 assert_eq!(126 assert_eq!(
123- counter("SELECT COALESCE(sum(registration_count), 0)::bigint FROM event", &db).await,127+ counter(
128+ "SELECT COALESCE(sum(registration_count), 0)::bigint FROM event",
129+ &db
130+ )
131+ .await,
124 0,132 0,
125 "the seat must be handed back, or the event is full forever"133 "the seat must be handed back, or the event is full forever"
126 );134 );
@@ -173,7 +181,11 @@ async fn a_promotion_keeps_the_signup_the_promoted_user_can_still_free() {
173 "a promotion must not destroy a signup its holder can still free"181 "a promotion must not destroy a signup its holder can still free"
174 );182 );
175 assert_eq!(183 assert_eq!(
176- counter("SELECT COALESCE(sum(registration_count), 0)::bigint FROM event", &db).await,184+ counter(
185+ "SELECT COALESCE(sum(registration_count), 0)::bigint FROM event",
186+ &db
187+ )
188+ .await,
177 1,189 1,
178 "…and the seat it holds stays claimed with it"190 "…and the seat it holds stays claimed with it"
179 );191 );
@@ -193,7 +205,11 @@ async fn a_promotion_keeps_the_signup_the_promoted_user_can_still_free() {
193 assert_eq!(res.status, StatusCode::NO_CONTENT, "{}", res.body);205 assert_eq!(res.status, StatusCode::NO_CONTENT, "{}", res.body);
194 assert_eq!(rows("SELECT count(*) FROM registration", &db).await, 0);206 assert_eq!(rows("SELECT count(*) FROM registration", &db).await, 0);
195 assert_eq!(207 assert_eq!(
196- counter("SELECT COALESCE(sum(registration_count), 0)::bigint FROM event", &db).await,208+ counter(
209+ "SELECT COALESCE(sum(registration_count), 0)::bigint FROM event",
210+ &db
211+ )
212+ .await,
197 0213 0
198 );214 );
199 }215 }
@@ -238,7 +254,11 @@ async fn a_demotion_leaves_a_frozen_signup_list_exactly_as_it_stands() {
238 "a closed roster must not be rewritten by a role change"254 "a closed roster must not be rewritten by a role change"
239 );255 );
240 assert_eq!(256 assert_eq!(
241- counter("SELECT COALESCE(sum(registration_count), 0)::bigint FROM event", &db).await,257+ counter(
258+ "SELECT COALESCE(sum(registration_count), 0)::bigint FROM event",
259+ &db
260+ )
261+ .await,
242 1,262 1,
243 "…and its seat stays claimed with it — the row is the seat"263 "…and its seat stays claimed with it — the row is the seat"
244 );264 );
@@ -303,7 +323,11 @@ async fn the_sweep_deletes_an_orphan_signup_instead_of_stranding_it() {
303 "an orphan signup must go with the rest — nothing else can ever remove it"323 "an orphan signup must go with the rest — nothing else can ever remove it"
304 );324 );
305 assert_eq!(325 assert_eq!(
306- counter("SELECT COALESCE(sum(registration_count), 0)::bigint FROM event", &db).await,326+ counter(
327+ "SELECT COALESCE(sum(registration_count), 0)::bigint FROM event",
328+ &db
329+ )
330+ .await,
307 0,331 0,
308 "and the surviving event still gets its seat back"332 "and the surviving event still gets its seat back"
309 );333 );
@@ -311,7 +335,7 @@ async fn the_sweep_deletes_an_orphan_signup_instead_of_stranding_it() {
311 335
312 /// How many boards list `user` as a participant, read out of the store.336 /// How many boards list `user` as a participant, read out of the store.
313 async fn boards_listing(user: &str, db: &Database) -> i64 {337 async fn boards_listing(user: &str, db: &Database) -> i64 {
314- sqlx::query_scalar("SELECT count(*) FROM board WHERE $1 = ANY(participants)")338+ sqlx::query_scalar("SELECT count(*) FROM board_participant WHERE participant = $1")
315 .bind(uuid::Uuid::parse_str(user).expect("a uuid user id"))339 .bind(uuid::Uuid::parse_str(user).expect("a uuid user id"))
316 .fetch_one(db)340 .fetch_one(db)
317 .await341 .await
@@ -486,7 +510,11 @@ async fn nothing_was_swept(ali_id: &str, db: &Database) {
486 "the enrollment must survive a failed cascade"510 "the enrollment must survive a failed cascade"
487 );511 );
488 assert_eq!(512 assert_eq!(
489- counter("SELECT COALESCE(sum(enrollment_count), 0)::bigint FROM course", db).await,513+ counter(
514+ "SELECT COALESCE(sum(enrollment_count), 0)::bigint FROM course",
515+ db
516+ )
517+ .await,
490 1,518 1,
491 "…and so must its seat, or the roster and the count disagree forever"519 "…and so must its seat, or the roster and the count disagree forever"
492 );520 );
@@ -501,7 +529,11 @@ async fn nothing_was_swept(ali_id: &str, db: &Database) {
501 "the signup must survive a failed cascade"529 "the signup must survive a failed cascade"
502 );530 );
503 assert_eq!(531 assert_eq!(
504- counter("SELECT COALESCE(sum(registration_count), 0)::bigint FROM event", db).await,532+ counter(
533+ "SELECT COALESCE(sum(registration_count), 0)::bigint FROM event",
534+ db
535+ )
536+ .await,
505 1,537 1,
506 "…with its seat still claimed"538 "…with its seat still claimed"
507 );539 );
@@ -546,11 +578,19 @@ async fn the_retry_takes_everything(
546 }578 }
547 assert_eq!(boards_listing(ali_id, db).await, 0);579 assert_eq!(boards_listing(ali_id, db).await, 0);
548 assert_eq!(580 assert_eq!(
549- counter("SELECT COALESCE(sum(enrollment_count), 0)::bigint FROM course", db).await,581+ counter(
582+ "SELECT COALESCE(sum(enrollment_count), 0)::bigint FROM course",
583+ db
584+ )
585+ .await,
550 0586 0
551 );587 );
552 assert_eq!(588 assert_eq!(
553- counter("SELECT COALESCE(sum(registration_count), 0)::bigint FROM event", db).await,589+ counter(
590+ "SELECT COALESCE(sum(registration_count), 0)::bigint FROM event",
591+ db
592+ )
593+ .await,
554 0594 0
555 );595 );
556 // The seat is usable, which is the whole point of freeing it: the one-seat596 // The seat is usable, which is the whole point of freeing it: the one-seat
@@ -585,7 +625,7 @@ async fn a_failure_late_in_the_cascade_leaves_the_old_role_and_every_grant_stand
585 let (app, db) = app_and_db().await;625 let (app, db) = app_and_db().await;
586 let (admin, teacher, ali_id) = a_student_holding_every_grant(&app, &db).await;626 let (admin, teacher, ali_id) = a_student_holding_every_grant(&app, &db).await;
587 627
588- poison("board", "UPDATE", &db).await;628+ poison("board_participant", "DELETE", &db).await;
589 let res = send(629 let res = send(
590 &app,630 &app,
591 "PATCH",631 "PATCH",
@@ -602,7 +642,7 @@ async fn a_failure_late_in_the_cascade_leaves_the_old_role_and_every_grant_stand
602 );642 );
603 nothing_was_swept(&ali_id, &db).await;643 nothing_was_swept(&ali_id, &db).await;
604 644
605- unpoison("board", &db).await;645+ unpoison("board_participant", &db).await;
606 the_retry_takes_everything(&app, &db, &admin, &teacher, &ali_id).await;646 the_retry_takes_everything(&app, &db, &admin, &teacher, &ali_id).await;
607 }647 }
608 648