Skip to content

Commit 2171a17

Browse files
Fix errcheck in ./common/rpc/ (#3752)
1 parent 3cb9232 commit 2171a17

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

common/rpc/interceptor/caller_info_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (s *callerInfoSuite) TestIntercept_CallerName() {
125125
ctx := testCase.setupIncomingCtx()
126126

127127
var resultingCtx context.Context
128-
s.interceptor.Intercept(
128+
_, err := s.interceptor.Intercept(
129129
ctx,
130130
testCase.request,
131131
&grpc.UnaryServerInfo{},
@@ -134,6 +134,7 @@ func (s *callerInfoSuite) TestIntercept_CallerName() {
134134
return nil, nil
135135
},
136136
)
137+
s.NoError(err)
137138

138139
actualCallerName := headers.GetCallerInfo(resultingCtx).CallerName
139140
s.Equal(testCase.expectedCallerName, actualCallerName)
@@ -186,7 +187,7 @@ func (s *callerInfoSuite) TestIntercept_CallerType() {
186187
ctx := testCase.setupIncomingCtx()
187188

188189
var resultingCtx context.Context
189-
s.interceptor.Intercept(
190+
_, err := s.interceptor.Intercept(
190191
ctx,
191192
testCase.request,
192193
&grpc.UnaryServerInfo{},
@@ -195,6 +196,7 @@ func (s *callerInfoSuite) TestIntercept_CallerType() {
195196
return nil, nil
196197
},
197198
)
199+
s.NoError(err)
198200

199201
actualCallerType := headers.GetCallerInfo(resultingCtx).CallerType
200202
s.Equal(testCase.expectedCallerType, actualCallerType)
@@ -259,7 +261,7 @@ func (s *callerInfoSuite) TestIntercept_CallOrigin() {
259261
ctx := testCase.setupIncomingCtx()
260262

261263
var resultingCtx context.Context
262-
s.interceptor.Intercept(
264+
_, err := s.interceptor.Intercept(
263265
ctx,
264266
testCase.request,
265267
serverInfo,
@@ -268,6 +270,7 @@ func (s *callerInfoSuite) TestIntercept_CallOrigin() {
268270
return nil, nil
269271
},
270272
)
273+
s.NoError(err)
271274

272275
actualCallOrigin := headers.GetCallerInfo(resultingCtx).CallOrigin
273276
s.Equal(testCase.expectedCallOrigin, actualCallOrigin)

common/rpc/interceptor/sdk_version_test.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,38 @@ func TestSDKVersionRecorder(t *testing.T) {
4747

4848
// Record first tuple
4949
ctx := headers.SetVersionsForTests(context.Background(), sdkVersion, headers.ClientNameGoSDK, headers.SupportedServerVersions, headers.AllFeatures)
50-
interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
50+
_, err := interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
5151
return nil, nil
5252
})
53+
assert.NoError(t, err)
5354

5455
// Record second tuple
5556
ctx = headers.SetVersionsForTests(context.Background(), sdkVersion, headers.ClientNameTypeScriptSDK, headers.SupportedServerVersions, headers.AllFeatures)
56-
interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
57+
_, err = interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
5758
return nil, nil
5859
})
60+
assert.NoError(t, err)
5961

6062
// Do not record when over capacity
6163
ctx = headers.SetVersionsForTests(context.Background(), sdkVersion, headers.ClientNameJavaSDK, headers.SupportedServerVersions, headers.AllFeatures)
62-
interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
64+
_, err = interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
6365
return nil, nil
6466
})
67+
assert.NoError(t, err)
6568

6669
// Empty SDK version should not be recorded
6770
ctx = headers.SetVersionsForTests(context.Background(), "", headers.ClientNameGoSDK, headers.SupportedServerVersions, headers.AllFeatures)
68-
interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
71+
_, err = interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
6972
return nil, nil
7073
})
74+
assert.NoError(t, err)
7175

7276
// Empty SDK name should not be recorded
7377
ctx = headers.SetVersionsForTests(context.Background(), sdkVersion, "", headers.SupportedServerVersions, headers.AllFeatures)
74-
interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
78+
_, err = interceptor.Intercept(ctx, nil, nil, func(ctx context.Context, req interface{}) (interface{}, error) {
7579
return nil, nil
7680
})
81+
assert.NoError(t, err)
7782

7883
info := interceptor.GetAndResetSDKInfo()
7984
sort.SliceStable(info, func(i, j int) bool {

0 commit comments

Comments
 (0)