Route the delivery tests' gorm.Open through gormlog (closes #462) #466

Merged
clawbot merged 1 commits from issue-462-test-gorm-logger into next 2026-10-02 20:20:49 +02:00
Collaborator

The six gorm.Open calls in the internal/delivery tests (archive_sweeper_test.go three times, engine_test.go, engine_integration_test.go, target_database_test.go) passed a bare &gorm.Config{}, which installs GORM's default logger. Each now passes gormlog.New over an slog logger with slog.DiscardHandler, so no gorm.Open in the tree is left on the bare form for someone to copy into production code. No existing test helper discards: archiveTestLogger writes to standard error at debug level, so wrapping it would have printed every test statement.

README.md and the ParamsFilter comment in internal/gormlog/gormlog.go said (*gorm.DB).Scan had one caller, internal/database/database_test.go:91. That is stale: internal/database/event_tier_indexes_test.go calls it too, with bound values. Both now say only tests call it and what a test binds is fixture data, the wording the guard test already uses, so the sentence does not go stale again when a test adds a call.

A side effect worth knowing: these test databases no longer write through gormlogger.Default, so the two tests that swap that process-global logger to catch a bare config in production no longer share it with them.

Model: opus-5-5

The six `gorm.Open` calls in the `internal/delivery` tests (`archive_sweeper_test.go` three times, `engine_test.go`, `engine_integration_test.go`, `target_database_test.go`) passed a bare `&gorm.Config{}`, which installs GORM's default logger. Each now passes `gormlog.New` over an `slog` logger with `slog.DiscardHandler`, so no `gorm.Open` in the tree is left on the bare form for someone to copy into production code. No existing test helper discards: `archiveTestLogger` writes to standard error at debug level, so wrapping it would have printed every test statement. `README.md` and the `ParamsFilter` comment in `internal/gormlog/gormlog.go` said `(*gorm.DB).Scan` had one caller, `internal/database/database_test.go:91`. That is stale: `internal/database/event_tier_indexes_test.go` calls it too, with bound values. Both now say only tests call it and what a test binds is fixture data, the wording the guard test already uses, so the sentence does not go stale again when a test adds a call. A side effect worth knowing: these test databases no longer write through `gormlogger.Default`, so the two tests that swap that process-global logger to catch a bare config in production no longer share it with them. Model: opus-5-5
clawbot added the needs-review label 2026-10-02 20:02:16 +02:00
clawbot self-assigned this 2026-10-02 20:02:16 +02:00
clawbot added 1 commit 2026-10-02 20:02:16 +02:00
The six gorm.Open calls in the internal/delivery tests passed a bare
gorm.Config, which installs GORM's default logger; they now pass
gormlog.New over a logger that discards, as every production call does,
so the unfiltered form is no longer in the tree to be copied.

The README and the ParamsFilter comment said (*gorm.DB).Scan had one
test-only caller; there are more. Both now say only tests call it, with
fixture data.

Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 4915d60d8e into next 2026-10-02 20:20:49 +02:00
clawbot deleted branch issue-462-test-gorm-logger 2026-10-02 20:20:49 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#466