mock

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPClient

func HTTPClient(requests ...*Request) (*http.Client, string, func() error)

HTTPClient returns an *http.Client, URL, and cleanup function. The http.Client is configured to connect to test SSL Server at the returned URL. This server will respond to HTTP requests defined, or return a 5xx server error for unexpected ones. The cleanup function will close the server, and return an error if any expected calls weren't received.

func StartServerProxy

func StartServerProxy(t *testing.T, inst FakeAlloyDBInstance) func()

StartServerProxy starts a fake server proxy and listens on the provided port on all interfaces, configured with TLS as specified by the FakeAlloyDBInstance. Callers should invoke the returned function to clean up all resources.

Types

type FakeAlloyDBInstance

type FakeAlloyDBInstance struct {
	// contains filtered or unexported fields
}

func NewFakeInstance

func NewFakeInstance(proj, reg, clust, name string, opts ...Option) FakeAlloyDBInstance

type Option

type Option func(*FakeAlloyDBInstance)

func WithCertExpiry

func WithCertExpiry(expiry time.Time) Option

func WithIPAddr

func WithIPAddr(addr string) Option

func WithServerName added in v0.2.0

func WithServerName(name string) Option

type Request

type Request struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Request represents a HTTP request for a test Server to mock responses for.

Use NewRequest to initialize new Requests.

func CreateEphemeralSuccess

func CreateEphemeralSuccess(i FakeAlloyDBInstance, ct int) *Request

CreateEphemeralSuccess returns a Request that responds to the `generateEphemeralCert` AlloyDB Admin API endpoint.

func InstanceGetSuccess

func InstanceGetSuccess(i FakeAlloyDBInstance, ct int) *Request

InstanceGetSuccess returns a Request that responds to the `instance.get` AlloyDB Admin API endpoint.

Jump to

Keyboard shortcuts

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