Skip to content

Commit

Permalink
Enforce 5 minutes default test timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Jul 27, 2023
1 parent 01d7935 commit bf10df8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/test/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"strconv"
"testing"
"time"

"github.com/hashicorp/go-azure-sdk/sdk/auth"
"github.com/hashicorp/go-azure-sdk/sdk/claims"
Expand Down Expand Up @@ -140,10 +141,12 @@ type Test struct {

func NewTest(t *testing.T) (c *Test) {
ctx := context.Background()
var cancel context.CancelFunc = func() {}
var cancel context.CancelFunc

if deadline, ok := t.Deadline(); ok {
ctx, cancel = context.WithDeadline(context.Background(), deadline)
ctx, cancel = context.WithDeadline(ctx, deadline)
} else {
ctx, cancel = context.WithTimeout(ctx, 5*time.Minute)
}

c = &Test{
Expand Down

0 comments on commit bf10df8

Please sign in to comment.