awstesting

package
v1.50.30 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 29 Imported by: 3

README

AWS SDK for Go awstesting packages

awstesting is a collection of packages used internally by the SDK, and is subject to have breaking changes. This package is not internal so that if you really need to use its functionality, and understand breaking changes will be made, you are able to.

These packages will be refactored in the future so that the API generator and model parsers are exposed cleanly on their own.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TLSBundleCA is the CA PEM
	TLSBundleCA []byte

	// TLSBundleCert is the Server PEM
	TLSBundleCert []byte

	// TLSBundleKey is the Server private key PEM
	TLSBundleKey []byte

	// ClientTLSCert is the Client PEM
	ClientTLSCert []byte

	// ClientTLSKey is the Client private key PEM
	ClientTLSKey []byte
)

Functions

func AssertJSON

func AssertJSON(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool

AssertJSON verifies that the expect json string matches the actual.

func AssertQuery

func AssertQuery(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool

AssertQuery verifies the expect HTTP query string matches the actual.

func AssertURL

func AssertURL(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool

AssertURL verifies the expected URL is matches the actual.

func AssertXML

func AssertXML(t *testing.T, expect, actual string, msgAndArgs ...interface{}) bool

AssertXML verifies that the expect XML string matches the actual.

func CleanupTLSBundleFiles added in v1.8.24

func CleanupTLSBundleFiles(files ...string) error

CleanupTLSBundleFiles takes variadic list of files to be deleted.

func CreateClientTLSCertFiles added in v1.36.5

func CreateClientTLSCertFiles() (cert, key string, err error)

CreateClientTLSCertFiles returns a set of temporary files for the client certificate and key files.

func CreateTLSBundleFiles added in v1.8.24

func CreateTLSBundleFiles() (cert, key, ca string, err error)

CreateTLSBundleFiles returns the temporary filenames for the certificate key, and CA PEM content. These files should be deleted when no longer needed. CleanupTLSBundleFiles can be used for this cleanup.

func CreateTLSServer added in v1.8.24

func CreateTLSServer(cert, key string, mux *http.ServeMux) (string, error)

CreateTLSServer will create the TLS server on an open port using the certificate and key. The address will be returned that the server is running on.

func DidPanic added in v1.12.2

func DidPanic(fn func()) (bool, interface{})

DidPanic returns if the function paniced and returns true if the function paniced.

func Match

func Match(t *testing.T, regex, expected string)

Match is a testing helper to test for testing error by comparing expected with a regular expression.

func NewClient added in v1.0.0

func NewClient(cfgs ...*aws.Config) *client.Client

NewClient creates and initializes a generic service client for testing.

func NewTLSClientCertServer added in v1.36.5

func NewTLSClientCertServer(handler http.Handler) (*httptest.Server, error)

NewTLSClientCertServer creates a new HTTP test server initialize to require HTTP clients authenticate with TLS client certificates.

func PopEnv deprecated added in v1.8.33

func PopEnv(env []string)

PopEnv takes the list of the environment values and injects them into the process's environment variable data. Clears any existing environment values that may already exist.

Deprecated: PopEnv exists for backward compatibility and may be removed from the future iterations. It is not `internal` so that if you really need to use its functionality, and understand breaking changes will be made, you are able to.

func SortedKeys

func SortedKeys(m map[string]interface{}) []string

SortedKeys returns a sorted slice of keys of a map.

func SprintExpectActual added in v1.8.33

func SprintExpectActual(expect, actual interface{}) string

SprintExpectActual returns a string for test failure cases when the actual value is not the same as the expected.

func StashEnv deprecated added in v1.8.33

func StashEnv() []string

StashEnv stashes the current environment variables and returns an array of all environment values as key=val strings.

Deprecated: StashEnv exists for backward compatibility and may be removed from the future iterations. It is not `internal` so that if you really need to use its functionality, and understand breaking changes will be made, you are able to.

Types

type DiscardAt added in v1.25.0

type DiscardAt struct{}

DiscardAt is an io.WriteAt that discards the requested bytes to be written

func (DiscardAt) WriteAt added in v1.25.0

func (d DiscardAt) WriteAt(p []byte, off int64) (n int, err error)

WriteAt discards the given []byte slice and returns len(p) bytes as having been written at the given offset. It will never return an error.

type EndlessReader added in v1.25.0

type EndlessReader struct{}

EndlessReader is an io.Reader that will always return that bytes have been read.

func (EndlessReader) Read added in v1.25.0

func (e EndlessReader) Read(p []byte) (int, error)

Read will report that it has read len(p) bytes in p. The content in the []byte will be unmodified. This will never return an error.

type FakeContext added in v1.8.0

type FakeContext struct {
	Error  error
	DoneCh chan struct{}
}

A FakeContext provides a simple stub implementation of a Context

func (*FakeContext) Deadline added in v1.8.0

func (c *FakeContext) Deadline() (deadline time.Time, ok bool)

Deadline always will return not set

func (*FakeContext) Done added in v1.8.0

func (c *FakeContext) Done() <-chan struct{}

Done returns a read channel for listening to the Done event

func (*FakeContext) Err added in v1.8.0

func (c *FakeContext) Err() error

Err returns the error, is nil if not set.

func (*FakeContext) Value added in v1.8.0

func (c *FakeContext) Value(key interface{}) interface{}

Value ignores the Value and always returns nil

type ReadCloser added in v1.1.10

type ReadCloser struct {
	Size   int
	Closed bool

	FillData func(bool, []byte, int, int)
	// contains filtered or unexported fields
}

ReadCloser is a io.ReadCloser for unit testing. Designed to test for leaks and whether a handle has been closed

func (*ReadCloser) Close added in v1.1.10

func (r *ReadCloser) Close() error

Close sets Closed to true and returns no error

func (*ReadCloser) Read added in v1.1.10

func (r *ReadCloser) Read(b []byte) (int, error)

Read will call FillData and fill it with whatever data needed. Decrements the size until zero, then return io.EOF.

type ZeroReader added in v1.1.1

type ZeroReader struct{}

ZeroReader is a io.Reader which will always write zeros to the byte slice provided.

func (*ZeroReader) Read added in v1.1.1

func (r *ZeroReader) Read(b []byte) (int, error)

Read fills the provided byte slice with zeros returning the number of bytes written.

Directories

Path Synopsis
Package unit performs initialization and validation for unit tests
Package unit performs initialization and validation for unit tests

Jump to

Keyboard shortcuts

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