Commit 26063f9
committed
test(api): make scheduled-revoke mock explicit + deterministic reservation test
CodeRabbit round 4:
TestRevokePurchase_ScheduledExecution_AdminFreeCancel relied on the shared mock
default for its CAS return and carried a comment naming the wrong method
(CancelExecutionAtomic), while a scheduled row is actually cancelled via
CancelScheduledExecutionAtomic. Stub that method explicitly with
Return(true, "cancelled", nil).Once() plus DeleteSuppressionsByExecutionTx,
matching the sibling scheduled-revoke tests. AssertExpectations now enforces the
stub, so the setup and the asserted status can never drift.
TestBuildReservationName_NilFieldsReturnsFallback rebuilt its expected value via
SanitizeReservationID("", prefix), which calls time.Now() a second time -- a
second-boundary cross between the actual call and the rebuild would flake the
equality assertion. Replace it with deterministic structural assertions: regexp
^rds-reserved-[0-9]+$ (sanitized prefix + unix timestamp), no trailing hyphen,
and the length cap. No second time.Now() comparison.
Verified by execution: go test ./internal/api/... (1636) and -run Revoke (33)
both green; reservation_name nil tests pass.1 parent 756ca62 commit 26063f9
2 files changed
Lines changed: 15 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
580 | 580 | | |
581 | 581 | | |
582 | 582 | | |
583 | | - | |
584 | | - | |
585 | | - | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
586 | 590 | | |
587 | 591 | | |
588 | 592 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | | - | |
24 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
0 commit comments