Skip to content

Instantly share code, notes, and snippets.

@RobinThrift
Last active October 7, 2022 14:38
Show Gist options
  • Save RobinThrift/b4f5ede313877ed6ef8f6ef15b5ac042 to your computer and use it in GitHub Desktop.
Save RobinThrift/b4f5ede313877ed6ef8f6ef15b5ac042 to your computer and use it in GitHub Desktop.
func createTestContext(t *testing.T) (context.Context, context.CancelFunc) {
if deadline, ok := t.Deadline(); ok {
return context.WithDeadline(context.Background(), deadline)
}
return context.WithTimeout(context.Background(), 10*time.Second)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment