testUtils

package
v0.0.0-...-41bf266 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: CC0-1.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CtxMatcher = mock.MatchedBy(func(ctx context.Context) bool { return true })

CtxMatcher allow us to validate that the caller supplied a context.Context argument See: https://github.com/stretchr/testify/issues/519

Functions

func ContextTransactionID

func ContextTransactionID() *http.Request

func CopyToS3

func CopyToS3(t *testing.T, src string) (string, func())

CopyToS3 copies all of the content found at src into a temporary S3 folder within localstack. The path to the temporary S3 directory is returned along with a function that can be called to clean up the data.

func CopyToTemporaryDirectory

func CopyToTemporaryDirectory(t *testing.T, src string) (string, func())

CopyToTemporaryDirectory copies all of the content found at src into a temporary directory. The path to the temporary directory is returned along with a function that can be called to clean up the data.

func GetLogger

func GetLogger(logger logrus.FieldLogger) *logrus.Logger

GetLogger returns the underlying implementation of the field logger

func GetRandomIPV4Address

func GetRandomIPV4Address(t *testing.T) string

GetRandomIPV4Address returns a random IPV4 address using rand.Read() to generate the values.

func ListS3Objects

func ListS3Objects(t *testing.T, bucket string, prefix string) []*s3.Object

func MakeDirToDelete

func MakeDirToDelete(s suite.Suite, filePath string)

func MakeTestServerWithAuthTokenRequestTimeout

func MakeTestServerWithAuthTokenRequestTimeout() *httptest.Server

func MakeTestServerWithBadAuthTokenRequest

func MakeTestServerWithBadAuthTokenRequest() *httptest.Server

func MakeTestServerWithBadRequest

func MakeTestServerWithBadRequest() *httptest.Server

func MakeTestServerWithInternalServerErrAuthTokenRequest

func MakeTestServerWithInternalServerErrAuthTokenRequest() *httptest.Server

func MakeTestServerWithIntrospectEndpoint

func MakeTestServerWithIntrospectEndpoint(activeToken bool) *httptest.Server

MakeTestServerWithIntrospectEndpoint creates an httptest.Server with an introspect endpoint that will return back a response with a json body indicating if "active" is set to true or false (set by active token parameter)

func MakeTestServerWithIntrospectReturn502

func MakeTestServerWithIntrospectReturn502() *httptest.Server

MakeTestServerWithIntrospectReturn502 creates an httptest.Server with an introspect endpoint that will return 502 Status Code.

func MakeTestServerWithIntrospectTimeout

func MakeTestServerWithIntrospectTimeout() *httptest.Server

MakeTestServerWithIntrospectTimeout creates an httptest.Server with an introspect endpoint that will sleep for 10 seconds. Useful in testing where the env timeout is set to something less (ex. 5 seconds) and you want to ensure *url.Error.Timeout() returns true.

func MakeTestServerWithInvalidAuthTokenRequest

func MakeTestServerWithInvalidAuthTokenRequest() *httptest.Server

func MakeTestServerWithInvalidCarriage

func MakeTestServerWithInvalidCarriage() *httptest.Server

func MakeTestServerWithInvalidTokenRequest

func MakeTestServerWithInvalidTokenRequest() *httptest.Server

func MakeTestServerWithTokenRequestTimeout

func MakeTestServerWithTokenRequestTimeout() *httptest.Server

func MakeTestServerWithValidAuthTokenRequest

func MakeTestServerWithValidAuthTokenRequest() *httptest.Server

func MakeTestServerWithValidTokenRequest

func MakeTestServerWithValidTokenRequest() *httptest.Server

func PrintSeparator

func PrintSeparator()

PrintSeparator prints a line of stars to stdout

func RandomBase64

func RandomBase64(n int) string

func RandomHexID

func RandomHexID() string

func RandomMBI

func RandomMBI(t *testing.T) string

RandomMBI returns an 11 character string that represents an MBI

func ReadResponseBody

func ReadResponseBody(r *http.Response) string

ReadResponseBody will read http.Response and return the body contents as a string.

func SetAndRestoreEnvKey

func SetAndRestoreEnvKey(key, value string) func()

SetAndRestoreEnvKey replaces the current value of the env var key, returning a function which can be used to restore the original value

func SetPendingDeletionDir

func SetPendingDeletionDir(s suite.Suite, path string)

SetPendingDeletionDir sets the PENDING_DELETION_DIR to the supplied "path" and ensures that the directory is created

Types

This section is empty.

Jump to

Keyboard shortcuts

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