testing
Technical notes on web development, DevOps, and AI integration.
59 articles
- 03:53tooling
The Auditor Uses the Same Ruler as the Gate
An audit report accused eight documentation commits of missing trailers; all eight were false positives. One filter line aligned the auditor with the gate.
TL;DR: The audit flagged nineteen commits missing Security-review trailers, but eight were false positives on QA and doc paths the commit gate has always exempt. Root cause: the auditor didn't share the gate's exemption list, so two versions of one policy drifted apart. Fix is a one-line filter reusing the gate's constant, proven red-first by a selftest.
#git#bash#testing - 03:01testing
Checksummed Evidence: Test Numbers Are Claims Until Verified
Raw verification output wrapped in a self-checksum makes agent numbers tamper-evident, while a fail-closed gate rejects slices without anchored review verdicts.
TL;DR: The author learned that an agent-reported "all tests passed" without raw output is a claim, not evidence. The fix: a shell script bundling command, output, and exit code, sealed with a self-verifying sha256 digest, plus a fail-closed gate requiring anchored review approvals. Honest limitation: same-session checksums only catch cheap forgery, not determined attackers.
#ai-agents#testing#qa - 00:58testing
The test that could not fail
An exit-code assertion can be satisfied by another path entirely. The fix pins the assertion to widened output.
TL;DR: A CLI feature test that only checks the exit code passed even after the feature was deleted, proving the assertion was vacuous. The fix captures stdout and asserts the seed actually widened into a known task ID. Lesson: assert on observable effects, not status codes.
#testing#python#mutation-testing - 23:53database
Down to Zero: The Rollback Path That Never Ran
Checkpoint v56 was built on an untested theory. Two down-file bugs, errors 1553 and 1364, surfaced the day down-to-0 ran again.
TL;DR: Migrations down to zero failed below checkpoint 56, disproving the untested ENUM theory behind it. Two rotted down files broke: a missing slug column and a dropped index that a foreign key depended on. A roundtrip test now proves the chain reversibility, replacing theory with measurable guarantees.
#database-migration#mysql#golang-migrate - 21:24backend
The Safe Boundary: Why the Roundtrip Test Stops at Checkpoint 56
The down chain breaks mid-way: an old down migration inserts an ENUM value that no longer exists there. Checkpoint 56 is the tested safe window.
TL;DR: The migration roundtrip test stops at version 56 instead of unwinding to zero, because a cross-dependency between migrations 45 and 51 breaks any deeper descent. Version 56 is the deepest proven-safe checkpoint, verified with spot-checks on 8 tables and 12 columns. A separate test pins the dev-only login route to return 404 everywhere except development.
#golang#golang-migrate#mysql - 20:45testing
Coverage Percentage Is Not a Shield: Lock the Reject Arms
A Go middleware coverage audit from 27 to 96.7 percent: what httptest arm-by-arm reject-path testing teaches, from JWT to CORS.
TL;DR: A coverage audit showed middleware at 27 percent despite guarding authentication, and the untested paths were all security-critical rejections. Walking arm by arm with Go's httptest added 850 lines across seven files, pushing middleware to 96.7 percent without changing production code. Coverage stops climbing where fakes start lying, so each rejection arm now gets a named test immediately.
#golang#testing#security - 14:00security
Five Security Holes, Locked Instead of Fixed
A tests-only commit turns five weak authentication behaviors into a named inventory with owner-decision markers.
TL;DR: Instead of silently fixing five weak security behaviors, the author locked them as characterization tests with owner-decision markers. Findings include account enumeration via registration, unthrottled OTP verification, non-revoked JWTs, orphaned OTP rows, and in-memory rate-limiter state. Mapping first beats fixing from memory: each weakness becomes a prioritized decision ticket.
#testing#security#authentication - 13:09backend
Review Moderation State Machine: State Transition Validation Through Integration Testing
Integration tests prove the review moderation machine: a wrong 9.9/999 seed, Remove filling the audit trail, Restore clearing it, aggregates recomputed both ways.
TL;DR: Integration tests inject absurd aggregates and verify Remove triggers real recalculation through production logic, not test-only updates. The moderation flow atomically flips approved to removed, fills four audit columns, enforces whitelisted reasons, and blocks double removal with ErrNotFound, while restore reverses everything. Table-driven tests covering boundaries, duplication, and pagination turn state transitions into a guaranteed contract.
#go#testing#mysql - 12:14testing
The Sneaky LIKE Assertion: When 1 Catches 19
A LIKE pattern over serialized JSON made an integration assertion flaky: object 1 caught object 19 through a substring collision.
TL;DR: A LIKE pattern meant to find JSON object 1 also matched objects 16 and 19, since substring matching treats them as prefixes. The flake hid because fixture ordering kept the right row first until data shifted. Fix by comparing parsed values or using JSON functions like JSON_SEARCH instead of loose string matching.
#testing#mysql#flaky-tests