Skip to content

Commit 51bff5f

Browse files
authored
[chore]: enable fatcontext linter (open-telemetry#13445)
#### Description Enable and fixes [fatcontext](https://golangci-lint.run/usage/linters/#fatcontext) linter --------- Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 84e2995 commit 51bff5f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ linters:
2626
- depguard
2727
- errcheck
2828
- errorlint
29+
- fatcontext
2930
- gocritic
3031
- gosec
3132
- govet

config/configgrpc/configgrpc_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -888,14 +888,16 @@ func TestStreamInterceptorEnhancesClient(t *testing.T) {
888888
inCtx := peer.NewContext(context.Background(), &peer.Peer{
889889
Addr: &net.IPAddr{IP: net.IPv4(1, 1, 1, 1)},
890890
})
891-
var outContext context.Context
892891

893892
stream := &mockedStream{
894893
ctx: inCtx,
895894
}
896895

896+
var handlerCalled bool
897897
handler := func(_ any, stream grpc.ServerStream) error {
898-
outContext = stream.Context()
898+
handlerCalled = true
899+
cl := client.FromContext(stream.Context())
900+
assert.Equal(t, "1.1.1.1", cl.Addr.String())
899901
return nil
900902
}
901903

@@ -904,9 +906,7 @@ func TestStreamInterceptorEnhancesClient(t *testing.T) {
904906

905907
// verify
906908
require.NoError(t, err)
907-
908-
cl := client.FromContext(outContext)
909-
assert.Equal(t, "1.1.1.1", cl.Addr.String())
909+
assert.True(t, handlerCalled, "the handler should have been called")
910910
}
911911

912912
type mockedStream struct {

0 commit comments

Comments
 (0)