mock

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 23 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
}

FakeAlloyDBInstance represents the server side proxy.

func NewFakeInstance

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

NewFakeInstance creates a Fake AlloyDB instance.

type Option

type Option func(*FakeAlloyDBInstance)

Option configures a FakeAlloyDBInstance

func WithCertExpiry

func WithCertExpiry(expiry time.Time) Option

WithCertExpiry sets the expiration time of the fake instance

func WithPSC added in v1.9.0

func WithPSC(addr string) Option

WithPSC sets the PSC address to addr.

func WithPrivateIP added in v1.6.0

func WithPrivateIP(addr string) Option

WithPrivateIP sets the private IP address to addr.

func WithPublicIP added in v1.6.0

func WithPublicIP(addr string) Option

WithPublicIP sets the public IP address to addr.

func WithServerName added in v0.2.0

func WithServerName(name string) Option

WithServerName sets the name that server uses to identify itself in the TLS handshake.

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 `generateClientCertificate` 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