Skip to content

Commit 9cb967d

Browse files
committed
add context with timeout to method_logger_test in binary log
1 parent 150515f commit 9cb967d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/binarylog/method_logger_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import (
3333
"google.golang.org/protobuf/types/known/durationpb"
3434
)
3535

36+
const defaultTestTimeout = 10 * time.Second
37+
3638
func (s) TestLog(t *testing.T) {
3739
idGen.reset()
3840
ml := NewTruncatingMethodLogger(10, 10)
@@ -336,7 +338,9 @@ func (s) TestLog(t *testing.T) {
336338
for i, tc := range testCases {
337339
buf.Reset()
338340
tc.want.SequenceIdWithinCall = uint64(i + 1)
339-
ml.Log(context.Background(), tc.config)
341+
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
342+
defer cancel()
343+
ml.Log(ctx, tc.config)
340344
inSink := new(binlogpb.GrpcLogEntry)
341345
if err := proto.Unmarshal(buf.Bytes()[4:], inSink); err != nil {
342346
t.Errorf("failed to unmarshal bytes in sink to proto: %v", err)

0 commit comments

Comments
 (0)