testutil
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- Constants
- func Context(t *testing.T, dur time.Duration) context.Context
- func CreateTemp(t *testing.T, dir, pattern string) *os.File
- func Eventually(ctx context.Context, t testing.TB, ...) (done bool)
- func GenerateTLSCertificate(t testing.TB, commonName string) tls.Certificate
- func InCI() bool
- func RaceEnabled() bool
- func SkipIfNotTiming(t *testing.T)
- func TempFile(t *testing.T, dir, pattern string) string
- type OAuth2Config
- type OAuth2TokenSource
Constants¶
const (WaitShort = 10 *time.SecondWaitMedium = 15 *time.SecondWaitLong = 25 *time.SecondWaitSuperLong = 60 *time.Second)
Constants for timing out operations, usable for creating contextsthat timeout or in require.Eventually.
const (IntervalFast = 25 *time.MillisecondIntervalMedium = 250 *time.MillisecondIntervalSlow =time.Second)
Constants for delaying repeated operations, e.g. inrequire.Eventually.
Variables¶
This section is empty.
Functions¶
funcCreateTemp¶added inv0.15.0
CreateTemp is a convenience function for creating a temporary file, likeos.CreateTemp, but it also registers a cleanup function to close and removethe file.
funcEventually¶added inv0.8.3
func Eventually(ctxcontext.Context, ttesting.TB, condition func(ctxcontext.Context) (donebool), ticktime.Duration, msgAndArgs ...interface{}) (donebool)
Eventually is like require.Eventually except it allows passinga context into the condition. It is safe to use with `require.*`.
If ctx times out, the test will fail, but not immediately.It is the caller's responsibility to exit early if required.
It is the caller's responsibility to ensure that ctx has adeadline or timeout set. Eventually will panic if this is notthe case in order to avoid potentially waiting forever.
condition is not run in a goroutine; use the providedcontext argument for cancellation if required.
funcGenerateTLSCertificate¶added inv0.10.0
func GenerateTLSCertificate(ttesting.TB, commonNamestring)tls.Certificate
funcRaceEnabled¶added inv0.26.0
func RaceEnabled()bool
RaceEnabled returns whether the race detector is enabled.This is a constant at compile time. It should be used toconditionally skip tests that are known to be sensitive tobeing run with the race detector enabled.Please use sparingly and as a last resort.
funcSkipIfNotTiming¶added inv0.23.1
Types¶
typeOAuth2Config¶added inv0.20.1
type OAuth2Config struct {Token *oauth2.TokenTokenSourceFuncOAuth2TokenSource}
func (*OAuth2Config)AuthCodeURL¶added inv0.20.1
func (*OAuth2Config) AuthCodeURL(statestring, _ ...oauth2.AuthCodeOption)string
func (*OAuth2Config)Exchange¶added inv0.20.1
func (c *OAuth2Config) Exchange(_context.Context, _string, _ ...oauth2.AuthCodeOption) (*oauth2.Token,error)
func (*OAuth2Config)TokenSource¶added inv0.20.1
func (c *OAuth2Config) TokenSource(_context.Context, _ *oauth2.Token)oauth2.TokenSource