THE PROBLEM
A success message needs evidence from the database.
The endpoint stores a project enquiry and increments a daily submission count in one batch. A historical mismatch between the count and current records prompted a review. Its original cause remains unverified, so the improvement focused on a behavior we could test: never acknowledge a batch if either reported result is unsuccessful.
Check both writes
The API inspects the result count and each result's success flag before returning an accepted response.
Exercise failure paths
Automated tests inject a database exception and a batch with one failed result. Neither path may report the enquiry as received.
Reject unsafe input early
Tests also verify invalid and honeypot submissions do not call the database batch at all.
VERIFIED BEHAVIOR
Clear outcomes for the cases we tested.
- Two successful results: acknowledge with a reference.
- Exception or one failed result: return an error, not a false success.
- Invalid or honeypot input: no database write attempted.