Skip to content

Commit 24af70c

Browse files
committed
fix: checkQuorumCall: avoid passing in ctx (deepsource)
Deepsource wants ctx to be the first argument, even in tests helpers.
1 parent d1c45c5 commit 24af70c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

client_interceptor_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ func testContext(t *testing.T, timeout time.Duration) context.Context {
3131

3232
// checkQuorumCall returns true if the quorum call was successful.
3333
// It returns false if an error occurred or the context timed out.
34-
func checkQuorumCall(t *testing.T, ctx context.Context, err error) bool {
34+
func checkQuorumCall(t *testing.T, ctxErr, err error) bool {
3535
t.Helper()
36-
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
37-
t.Error(ctx.Err())
36+
if errors.Is(ctxErr, context.DeadlineExceeded) {
37+
t.Error(ctxErr)
3838
return false
3939
}
4040
if err != nil {
@@ -363,7 +363,7 @@ func TestInterceptorIntegration_MajorityQuorum(t *testing.T) {
363363
mock.TestMethod,
364364
MajorityQuorum[*pb.StringValue, *pb.StringValue],
365365
)
366-
if !checkQuorumCall(t, ctx, err) {
366+
if !checkQuorumCall(t, ctx.Err(), err) {
367367
return
368368
}
369369
if got, want := result.GetValue(), "echo: test"; got != want {
@@ -384,7 +384,7 @@ func TestInterceptorIntegration_CustomAggregation(t *testing.T) {
384384
mock.GetValueMethod,
385385
sumInterceptor,
386386
)
387-
if !checkQuorumCall(t, ctx, err) {
387+
if !checkQuorumCall(t, ctx.Err(), err) {
388388
return
389389
}
390390
// Expected: 10 + 20 + 30 = 60
@@ -410,7 +410,7 @@ func TestInterceptorIntegration_Chaining(t *testing.T) {
410410
MajorityQuorum[*pb.StringValue, *pb.StringValue], // Base
411411
loggingInterceptor[*pb.StringValue, *pb.StringValue](tracker), // Interceptor
412412
)
413-
if !checkQuorumCall(t, ctx, err) {
413+
if !checkQuorumCall(t, ctx.Err(), err) {
414414
return
415415
}
416416
if result.GetValue() != "echo: test" {
@@ -472,7 +472,7 @@ func TestInterceptorIntegration_CollectAll(t *testing.T) {
472472
mock.TestMethod,
473473
CollectAllResponses[*pb.StringValue, *pb.StringValue],
474474
)
475-
if !checkQuorumCall(t, ctx, err) {
475+
if !checkQuorumCall(t, ctx.Err(), err) {
476476
return
477477
}
478478
if len(result) != 3 {
@@ -508,7 +508,7 @@ func TestInterceptorIntegration_PerNodeTransform(t *testing.T) {
508508
CollectAllResponses[*pb.StringValue, *pb.StringValue], // Base
509509
transformInterceptor, // Interceptor
510510
)
511-
if !checkQuorumCall(t, ctx, err) {
511+
if !checkQuorumCall(t, ctx.Err(), err) {
512512
return
513513
}
514514
if len(result) != 3 {
@@ -554,7 +554,7 @@ func TestInterceptorIntegration_PerNodeTransformSkip(t *testing.T) {
554554
CollectAllResponses[*pb.StringValue, *pb.StringValue], // Base
555555
transformInterceptor, // Interceptor
556556
)
557-
if !checkQuorumCall(t, ctx, err) {
557+
if !checkQuorumCall(t, ctx.Err(), err) {
558558
return
559559
}
560560
if len(result) != 2 {

0 commit comments

Comments
 (0)