hub (unreleased): review fix 7 — a test for the stuck line's guard: a row told to the operator never gets „the notice has not gone out”

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-15 17:19:01 +01:00
1 parent b391a2322c
commit cbfeeb626e
3 files changed
+44

No files matched your search

@@ -0,0 +1,7 @@
# Review finding 7 — the guard n.Told() in endNoticeStuck had no test. The new test, by mutation of the guard:
== MUTATION: the stuck line no longer asks whether somebody was told
RED on the mutant, GREEN on the real file
--- FAIL: TestReview7_ARowToldToTheOperatorNeverGetsTheStuckLine (0.05s)
end_notice_review_test.go:169: a row that was told to the operator got the „told nobody” line: [{ID:2 CustomerID:c1 EventType:offsite_end_notice_stuck Severity:warning Message:Off-site: the household c1 removed the app "vikunja" w
1 mutations, 0 not a red-proof
+5
View File
@@ -1,5 +1,10 @@
## Unreleased (after v0.182.0)
- **Review of the notice lock, finding 7 (2026-11-15 night): a test for a guard that had none.** `endNoticeStuck`
skips a row that was told (`n.Told() ||`); removing the guard left the suite green. New test
`TestReview7_ARowToldToTheOperatorNeverGetsTheStuckLine`: a row told to the operator whose later household mail
waits for the daily limit must not get the line „the notice has not gone out”. No code change; the guard's
removal is seen red.
- **Review of the notice lock, finding 2 (2026-11-15 night): a send that errors AFTER the mail service accepted it is
not mailed every hour.** A client timeout is logged `failed` although the mail may have gone; the notice was tried
again every hour and the daily limit counted only `sent` rows — 12 household mails in 12 hours in the review's
@@ -137,3 +137,35 @@ func TestReview2_ASendThatErrorsAfterItWasAcceptedIsNotMailedEveryHour(t *testin
})
}
}
// Finding 7. The guard `n.Told() ||` in endNoticeStuck had no test: without it the suite stayed green. A row that
// WAS told to the operator (the household had no address then) and whose later household mail waits for the daily
// limit has told somebody — the operator must NOT get the line „the notice has not gone out”.
func TestReview7_ARowToldToTheOperatorNeverGetsTheStuckLine(t *testing.T) {
r := newNoticeRig(t, "")
r.report(repPressed)
if n, _ := r.notice("vikunja"); n.ToldTo != store.EndNoticeOperator {
t.Fatalf("fixture: the operator was not told: %+v", n)
}
// five days pass; the household now has an address, and its daily limit is used up by other notices
old := time.Now().UTC().Add(-5 * 24 * time.Hour)
if err := r.st.SetEndNoticeForTest("c1", "vikunja", "2026-11-15T10:00:00Z", old, old, store.EndNoticeOperator); err != nil {
t.Fatal(err)
}
if err := r.st.SaveNotificationPrefs("c1", household, []string{}, 6); err != nil {
t.Fatal(err)
}
for i := 0; i < 5; i++ {
if err := r.st.LogNotification("c1", "offsite_end_scheduled", "info", "offsite_end_scheduled other", "sent", "", "customer"); err != nil {
t.Fatal(err)
}
}
r.report(repPressed)
n, _ := r.notice("vikunja")
if n.ToldTo != store.EndNoticeOperator || !n.Told() || !strings.Contains(n.LastReason, "daily limit") {
t.Fatalf("fixture: the household's mail must have waited for the limit, the operator's notice standing: %+v", n)
}
if e := r.events(offsitekeys.EventEndNoticeStuck); len(e) != 0 {
t.Fatalf("a row that was told to the operator got the „told nobody” line: %+v", e)
}
}