testutils

package
v0.37.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GivenCodeBuildIsEmpty

func GivenCodeBuildIsEmpty(t *testing.T, svc codebuildiface.CodeBuildAPI, codeBuildProject string)

func GivenSqsIsEmpty

func GivenSqsIsEmpty(t *testing.T, svc sqsiface.SQSAPI, sqsURL string)

func ReplaceMock

func ReplaceMock(m *mock.Mock, methodName string, arguments ...interface{}) *mock.Call

ReplaceMock allows you to mock out a method, overriding any previous expectations for that same method.

This is useful if you want to setup a generic stub object to reuse among multiple tests, but then tweak expectations for some of the tests.

Note that you need to pass the underlying mock object to this method, as `mock.Mock` does not expose any useful interfaces eg.

ReplaceMock(&myMock.Mock, "DoAThing", mock.Anything).Return(nil)

func Retry

func Retry(t *testing.T, maxAttempts int, sleep time.Duration, f func(r *R)) bool

Retry - Retries a test multiple times

Types

type R

type R struct {
	// The number of current attempt.
	Attempt int
	// contains filtered or unexported fields
}

R is passed to each run of a flaky test run, manages state and accumulates log statements.

func (*R) Errorf

func (r *R) Errorf(s string, v ...interface{})

Errorf is equivalent to Logf followed by Fail.

func (*R) Fail

func (r *R) Fail()

Fail marks the run as failed, and will retry once the function returns.

func (*R) FailNow

func (r *R) FailNow()

func (*R) Logf

func (r *R) Logf(s string, v ...interface{})

Logf formats its arguments and records it in the error log. The text is only printed for the final unsuccessful run or the first successful run.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL