Skip to content

Fix no-op logger setup in client test - #62

Merged
umputun merged 2 commits into
umputun:masterfrom
paskal:fix/client-test-log-setup
Aug 20, 2026
Merged

Fix no-op logger setup in client test#62
umputun merged 2 commits into
umputun:masterfrom
paskal:fix/client-test-log-setup

Conversation

@paskal

@paskal paskal commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

lgr.Out returns an Option; it does not change anything by itself. app/cmd/client_test.go:31-32 calls it twice as a bare statement, so the test neither redirects log output to io.Discard for its duration nor restores stdout afterwards, and TestClient prints through as before. Wrapping both calls in lgr.Setup, the form used everywhere else in the tree, makes the intent work.

staticcheck also reports the deferred line, though only on some toolchains, which is presumably why it has never shown up in CI. With the golangci-lint version pinned in .github/workflows/ci.yml:

$ golangci-lint cache clean && golangci-lint run      # darwin/arm64, go1.26.7
app/cmd/client_test.go:32:2: SA9010: deferred return function not called (staticcheck)
	defer lgr.Out(os.Stdout)

$ docker run --rm -v "$PWD":/app -w /app golangci/golangci-lint:v2.12.2 golangci-lint run
0 issues.                                             # linux/arm64, go1.26.2

The change clears it in both environments, and the tests pass with -race against mongo 4.4 and mongo 8.

paskal and others added 2 commits August 20, 2026 09:11
lgr.Out returns an Option, so calling it on its own builds the option and
discards it. The test intended to send log output to io.Discard for its
duration and restore stdout afterwards, and did neither; staticcheck
flags the deferred form as SA9010 under the pinned golangci-lint v2.12.2.
@umputun
umputun merged commit de162bb into umputun:master Aug 20, 2026
1 check passed
@paskal
paskal deleted the fix/client-test-log-setup branch August 20, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants