Documentation ¶
Index ¶
- Constants
- Variables
- func BinaryInPath(bin string) error
- func DeleteFromResult(t testing.TB, pth string, r gjson.Result) gjson.Result
- func GetFirstMatchResult(t testing.TB, rs []gjson.Result, k, v string) gjson.Result
- func GetJSONPaths(result gjson.Result) []string
- func GetLoggerFromT() *logger.Logger
- func GetResultStrSlice(rs []gjson.Result) []string
- func GetTerminalJSONPaths(result gjson.Result) []string
- func GetWD(t testing.TB) string
- func LoadJSON(t testing.TB, path string) gjson.Result
- func MinSemver(gotSemver string, minSemver string) error
- func NewTestFileLogger(t *testing.T, pth string) (*logger.Logger, func(t *testing.T))
- func ParseJSONResult(t testing.TB, j string) gjson.Result
- func ParseKubectlJSONResult(t testing.TB, str string) gjson.Result
- func Poll(t testing.TB, condition func() (bool, error), numRetries int, ...)
- func PollE(t testing.TB, condition func() (bool, error), numRetries int, ...) error
- func RandStr(l int) string
- func RunStage(stageName string, stage func())
- func SetEnv(t testing.TB, key string, value string)
- func StringFromTextAndArgs(msgAndArgs ...interface{}) string
- func ValFromEnv(t testing.TB, k string) string
- func WithHTTPClient(c *http.Client) assertOption
- func WithHTTPRequestRetries(count int, interval time.Duration) assertOption
- func WriteTmpFile(data string) (string, error)
- func WriteTmpFileWithExtension(data string, extension string) (string, error)
- type AssertHTTP
- func (ah *AssertHTTP) AssertResponse(t testing.TB, r *http.Request, wantCode int, want ...string)
- func (ah *AssertHTTP) AssertResponseWithRetry(t testing.TB, r *http.Request, wantCode int, want ...string)
- func (ah *AssertHTTP) AssertSuccess(t testing.TB, r *http.Request)
- func (ah *AssertHTTP) AssertSuccessWithRetry(t testing.TB, r *http.Request)
- type PollConditionError
- type PollParameterError
- type PollRetryLimitExceededError
- type TestFileLogger
Constants ¶
const RUN_STAGE_ENV_VAR = "RUN_STAGE"
Variables ¶
var (
KubectlTransientErrors = []string{
"E022[23] .* the server is currently unable to handle the request",
}
)
Kubectl transient errors
Functions ¶
func BinaryInPath ¶
BinaryInPath checks if a given binary is in path.
func DeleteFromResult ¶
DeleteFromResult deletes given path from result and returns the modified result
func GetFirstMatchResult ¶
GetFirstMatchResult returns the first matching result with a given k/v
func GetJSONPaths ¶ added in v0.17.0
GetJSONPaths returns a []string of all possible JSON paths for a gjson.Result
func GetLoggerFromT ¶
GetLoggerFromT returns a logger based on test verbosity
func GetResultStrSlice ¶
GetResultStrSlice parses results into a string slice
func GetTerminalJSONPaths ¶ added in v0.17.0
GetTerminalJSONPaths returns a []string of all terminal JSON paths for a gjson.Result
func LoadJSON ¶
LoadJSON reads and parses a json file into a gjson.Result. It fails test if not unable to parse.
func NewTestFileLogger ¶ added in v0.3.0
NewTestFileLogger returns a TestFileLogger logger that can be used with the WithLogger option.
func ParseJSONResult ¶
ParseJSONResult converts a JSON string into gjson result
func ParseKubectlJSONResult ¶ added in v0.17.0
Filter transient errors from kubectl output
func Poll ¶
Polls on a particular condition function while the returns true. It fails the test if the condition is not met within numRetries.
func PollE ¶ added in v0.8.0
func PollE(t testing.TB, condition func() (bool, error), numRetries int, interval time.Duration) error
Polls on a particular condition function while the returns true. Returns an error if the condition is not met within numRetries.
func RunStage ¶
func RunStage(stageName string, stage func())
RunStage runs stage if stageName matches RUN_STAGE env var or RUN_STAGE is unset. Similar to terratest RunStage but instead of skipping using env var, we match using envvar.
func StringFromTextAndArgs ¶ added in v0.10.0
func StringFromTextAndArgs(msgAndArgs ...interface{}) string
StringFromTextAndArgs converts msg and args to formatted text
func ValFromEnv ¶
ValFromEnv returns value for a given env var. It fails test if not set.
func WithHTTPClient ¶ added in v0.7.0
WithHTTPClient specifies an HTTP client for the AssertHTTP use.
func WithHTTPRequestRetries ¶ added in v0.8.0
WithHTTPRequestRetries specifies a HTTP request retry policy.
func WriteTmpFile ¶
WriteTmpFile writes data to a temp file and returns the path.
Types ¶
type AssertHTTP ¶ added in v0.7.0
type AssertHTTP struct {
// contains filtered or unexported fields
}
AssertHTTP provides a collection of HTTP asserts.
func NewAssertHTTP ¶ added in v0.7.0
func NewAssertHTTP(opts ...assertOption) *AssertHTTP
NewAssertHTTP creates a new AssertHTTP with option overrides.
func (*AssertHTTP) AssertResponse ¶ added in v0.7.0
func (ah *AssertHTTP) AssertResponse(t testing.TB, r *http.Request, wantCode int, want ...string)
AssertResponse runs httpResponse without retry.
func (*AssertHTTP) AssertResponseWithRetry ¶ added in v0.7.0
func (ah *AssertHTTP) AssertResponseWithRetry(t testing.TB, r *http.Request, wantCode int, want ...string)
AssertResponseWithRetry runs httpResponse and retries on errors outside client control.
func (*AssertHTTP) AssertSuccess ¶ added in v0.7.0
func (ah *AssertHTTP) AssertSuccess(t testing.TB, r *http.Request)
AssertSuccess runs httpRequest without retry.
func (*AssertHTTP) AssertSuccessWithRetry ¶ added in v0.7.0
func (ah *AssertHTTP) AssertSuccessWithRetry(t testing.TB, r *http.Request)
AssertSuccessWithRetry runs httpRequest and retries on errors outside client control.
type PollConditionError ¶ added in v0.8.0
type PollConditionError struct {
// contains filtered or unexported fields
}
PollConditionError is an error returned on the final PollE attempt.
func (*PollConditionError) Error ¶ added in v0.8.0
func (e *PollConditionError) Error() string
func (*PollConditionError) Unwrap ¶ added in v0.8.0
func (e *PollConditionError) Unwrap() error
type PollParameterError ¶ added in v0.8.0
type PollParameterError struct {
// contains filtered or unexported fields
}
PollParameterError is returend by PollE when input parameters are invalid.
func (*PollParameterError) Error ¶ added in v0.8.0
func (e *PollParameterError) Error() string
type PollRetryLimitExceededError ¶ added in v0.8.0
type PollRetryLimitExceededError struct {
// contains filtered or unexported fields
}
PollRetryLimitExceededError is returned by PollE when retries exceed numRetries.
func (*PollRetryLimitExceededError) Error ¶ added in v0.8.0
func (e *PollRetryLimitExceededError) Error() string
type TestFileLogger ¶ added in v0.3.0
type TestFileLogger struct {
// contains filtered or unexported fields
}
TestFileLogger is a logger that writes to disk instead of stdout. This is useful when you want to redirect verbose logs of long running tests to disk.
func (TestFileLogger) Close ¶ added in v0.3.0
func (fl TestFileLogger) Close(t *testing.T)
func (TestFileLogger) Logf ¶ added in v0.3.0
func (fl TestFileLogger) Logf(t terraTesting.TestingT, format string, args ...interface{})