testing
Technical notes on web development, DevOps, and AI integration.
83 articles
- 05:17testing
The package clause Line That Still Passes Build, Vet, and Test
A wrong package clause on a moved Go test file still passes go build, go vet, and go test. The import-binding rule behind it, and the procedural guard.
TL;DR: Moving a Go test file to a new directory silently broke its package clause: it still said package servicetype instead of servicetype_test. The build stayed green because unaliased imports share the import's name, so every servicetype.X call hit the import legally. Lesson: after relocating tests, manually check the package clause on line one, since tooling won't catch it.
#go#golang#testing - 04:27testing
Testing a Go Rate Limiter Without Waiting for Real Time
Swap the clock in Go tests: a rate limiter proven without sleep, plus when to graduate to testing/synctest.
TL;DR: Rate limiter tests shouldn't chase real time with time.Sleep, which makes them slow and flaky. Instead, expose a Now func() time.Time field on the struct and swap in a fixed clock, letting tests advance time instantly with no sleeps. For code that sleeps internally, Go's stable testing/synctest bubble fakes the clock.
#go#testing#rate-limit - 03:45backend
When to Export a Go Symbol
A test migration into external packages doubles as an API audit: three doors between public-path rewrites, real exports, and export_test.go.
TL;DR: Moving tests out of a package forces every internal function through one of three doors: rewrite via public paths, make a real export, or use export_test.go. A supposedly test-only commit exposed four importer functions worth exporting, revealing hidden API value. Test migrations double as free API audits, with zero exports signaling a healthy public interface.
#go#api-design#testing - 03:29backend
Moved the Tests, Coverage Went Up
Moving Go tests into a central tree as external _test packages forces rewrites through the public API, deletes dead helpers, and coverage rises.
TL;DR: Moving sixteen test files into a central tree looked purely mechanical, yet coverage rose instead of staying flat. Renaming packages to entityadmin_test forced black-box testing through public APIs, exposing dead helpers and internal-only tests along the way. Now _test packages are my default, export_test.go stays an emergency valve, and "mechanical" commit messages get more skepticism.
#go#testing#black-box-testing - 02:42testing
Zero Percent Coverage While Every Test Passes
Moving tests to a centralized tree makes per-package coverage read zero percent; one -coverpkg flag on the coverage mode restores the number.
TL;DR: Moving Go tests into a centralized external package caused coverage to drop to 0.0% even though everything still passes, because go test only instruments the package under test by default. The fix is the -coverpkg flag, which tells the tool which packages to measure. Execution and coverage are separate paths, so CI needs no changes.
#go#coverage#testing - 01:06backend
Reject Unknown Status Filters, Do Not Ignore Them
A characterization test demanded total = 3 for status=bogus, so the API answered 200 with every live row. One switch statement flipped it to fail-closed 400.
TL;DR: The endpoint silently ignored unrecognized status filters, returning all rows with 200 OK, and a green test had pinned that fail-open behavior as intended. A strict switch now separates empty string from invalid values, rejecting the latter with 400. Guidelines like AIP-160 agree, proving green tests don't guarantee a correct contract.
#golang#api#rest-api - 20:10testing
One Findings List for One Owner Decision
Four QA reports became one master table: 18 findings awaiting a decision, 4 not reproduced. Who decides matters more than ticket age.
TL;DR: Four QA reports consolidated into one FINDINGS.md master table: 18 awaiting owner decisions, 4 confirmed designed, 4 flaky E2E failures that didn't reproduce, 1 in progress. Consolidation exposed shared root causes and enabled risk-based ordering where impact, likelihood, and cheap fix beat ticket age. Work isn't closing tickets, it's ensuring every finding has an owner, a decision, and an order.
#testing#tooling - 20:04testing
Testing the Interface Against API Status Codes
A duplicate email returned a perfect 409 and an English toast in an Indonesian UI. The API was right; the translation layer failed twice.
TL;DR: QA tested 22 admin scenarios; 20 passed. Two failures were frontend translation issues, not backend bugs: a 409 conflict surfaced as an untranslated English toast, and a rejected fake image upload triggered no feedback at all despite the server correctly returning 400. Silent failures mislead more than wrong-language ones; localization belongs in the interface layer.
#testing#ux#api - 19:56testing
The Confirmation That Disappears: Wisata Admin QA
A QA session hit a delete click that vanished without deleting anything. The Playwright dialog contract explains why.
TL;DR: The disappearing confirm dialog wasn't an app bug; Playwright auto-dismisses native dialogs when no handler is registered, so destructive actions must go through the MCP browser_handle_dialog tool. Testing also found phone validation missing in two modules, folded into one cross-module ticket instead of two. Lesson: verify against tool contracts and database artifacts, not impressions.
#playwright#testing#mcp