Skip to content

Commit

Permalink
Change all context in bundle_test.go to context with timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
hasson82 committed Jun 19, 2024
1 parent 4a7ec24 commit 912de44
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/xds/bootstrap/tlscreds/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"fmt"
"strings"
"testing"
"time"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/tls/certprovider"
Expand All @@ -36,6 +37,8 @@ import (
"google.golang.org/grpc/testdata"
)

const defaultTestTimeout = 5 * time.Second

type s struct {
grpctest.Tester
}
Expand Down Expand Up @@ -85,7 +88,9 @@ func (s) TestFailingProvider(t *testing.T) {
defer conn.Close()

client := testgrpc.NewTestServiceClient(conn)
_, err = client.EmptyCall(context.Background(), &testpb.Empty{})
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
defer cancel()
_, err = client.EmptyCall(ctx, &testpb.Empty{})
if wantErr := "test error"; err == nil || !strings.Contains(err.Error(), wantErr) {
t.Errorf("EmptyCall() got err: %s, want err to contain: %s", err, wantErr)
}
Expand Down

0 comments on commit 912de44

Please sign in to comment.