Skip to content

Commit 832789b

Browse files
committed
move context creation to improve test readability
1 parent 0430481 commit 832789b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/xds/rbac/rbac_engine_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,12 +1747,13 @@ func (s) TestChainEngine(t *testing.T) {
17471747
// if the chain of RBAC Engines configured as such works as intended.
17481748
for _, data := range test.rbacQueries {
17491749
func() {
1750+
ctxWithTimeout, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
1751+
defer cancel()
17501752
// Construct the context with three data points that have enough
17511753
// information to represent incoming RPC's. This will be how a
17521754
// user uses this API. A user will have to put MD, PeerInfo, and
17531755
// the connection the RPC is sent on in the context.
1754-
ctx, cancel := context.WithTimeout(metadata.NewIncomingContext(context.Background(), data.rpcData.md), defaultTestTimeout)
1755-
defer cancel()
1756+
ctx := metadata.NewIncomingContext(ctxWithTimeout, data.rpcData.md)
17561757
// Make a TCP connection with a certain destination port. The
17571758
// address/port of this connection will be used to populate the
17581759
// destination ip/port in RPCData struct. This represents what

0 commit comments

Comments
 (0)