test: add tests for delivery, middleware, and session packages #32
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/webhooker#32
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/issue-28-test-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add comprehensive test coverage for three previously-untested packages, addressing issue #28.
Coverage Improvements
internal/deliveryinternal/middlewareinternal/sessionWhat's Tested
delivery (37% → 75%)
processNewTaskwith inline and large (DB-fetched) bodiesprocessRetryTasksuccess, skip non-retrying, large body fetchprocessDeliveryunknown target type handlingrecoverPendingDeliveries,recoverWebhookDeliveries,recoverInFlightNotifybatchingmiddleware (0% → 70%)
LoggingResponseWriterdelegationRequireAuthredirect for unauthenticated, pass-through for authenticatedMetricsAuthbasic auth validationipFromHostPorthelpersession (0% → 52%)
Get/Saveround-trip with real cookie storeSetUser,GetUserID,GetUsername,IsAuthenticatedClearUserremoves all keysDestroyinvalidates session (MaxAge -1)Test Helpers Added
database.NewTestDatabase/NewTestWebhookDBManager— cross-package test helpers for delivery integration testssession.NewForTest— creates session manager without fx lifecycle for middleware testsNotes
httptest, SQLite in-memory, and real cookie stores — no external network callsdocker build .passes (lint + test + build)closes #28
PR created for issue #28. Coverage improvements:
internal/deliveryinternal/middlewareinternal/sessiondocker build .passes (lint + test + build). All tests complete in ~3.5s.Code Review: PASS ✅
Reviewed: PR #32 — test coverage improvements for issue #28
Verification Results
_test.go+ 2testing.gohelpers, zero production code changesengine_test.goorcircuit_breaker_test.godocker build .passesmake check(format, lint, tests) all passTest Quality Assessment
internal/delivery/engine_integration_test.go(17 tests, 70 assertions)AutoMigratefor proper schemahttptestverifying actual request content (Content-Type headers, body content)require.Eventuallyfor async verificationinternal/middleware/middleware_test.go(16 tests, 36 assertions)*) vs prod mode (no CORS headers)RequireAuthwith real session round-trips (cookie create → set user → re-read)MetricsAuthwith valid/invalid/missing basic auth credentialsipFromHostPorthelper with table-driven subtestsinternal/session/session_test.go(16 tests, 71 assertions)SetUser/GetUserID/GetUsernamewith actual value verificationIsAuthenticatedacross all states (new, authenticated, cleared, wrong-type value)Destroysets MaxAge=-1 and clears all user keysNotes
testing.gohelper files (non-_test.go) are compiled into the production binary. This is a standard Go pattern for cross-package test helpers and is harmless since they're ininternal/packages. No action needed.t.Parallel()for speed.Labeling
merge-readyand assigning to @sneak for final review.