-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
small improvements to testing tools, specially InstallAgentForPolicy (#…
…3265) * remove missing verb on printf-like call upgrade integration test testStandaloneUpgrade. * make InstallAgentForPolicy receive a context and use either the context timeout or a 5-minutes default. * add new pkg/testing/tools/textcontext package The new package is for helper functions dealing with contexts and testing.T. It provides a WithDeadline function which respects t.Deadline() (cherry picked from commit f2eb134)
- Loading branch information
1 parent
f81c5be
commit 93e268e
Showing
5 changed files
with
56 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package testcontext | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
) | ||
|
||
// WithDeadline returns a context with a deadline. The deadline is the earliest | ||
// of either the provided 'deadline' or t.Deadline(). | ||
func WithDeadline( | ||
t *testing.T, | ||
parent context.Context, | ||
deadline time.Time) (context.Context, context.CancelFunc) { | ||
if d, ok := t.Deadline(); ok { | ||
deadline = d | ||
} | ||
ctx, cancel := context.WithDeadline(parent, deadline) | ||
return ctx, cancel | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters