mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-29 18:36:30 +02:00
* tests: use testcontainers for postgres * tests: use testcontainers for minio * remove gcs test * try installing docker * skip docker on macos
24 lines
483 B
Go
24 lines
483 B
Go
package testutil
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// GetContext gets a context for a testing.T.
|
|
func GetContext(t *testing.T, maxWait time.Duration) context.Context {
|
|
t.Helper()
|
|
|
|
ctx := context.Background()
|
|
ctx, clearTimeout := context.WithTimeout(ctx, maxWait)
|
|
t.Cleanup(clearTimeout)
|
|
|
|
if deadline, ok := t.Deadline(); ok {
|
|
var clearDeadline context.CancelFunc
|
|
ctx, clearDeadline = context.WithDeadline(ctx, deadline)
|
|
t.Cleanup(clearDeadline)
|
|
}
|
|
|
|
return ctx
|
|
}
|