testutil

package
v0.0.0-...-7983b3b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyECS

type DummyECS struct {
	Requests chan *http.Request
	// contains filtered or unexported fields
}

DummyECS allows tests to mock ECS metadata server responses

func NewDummyECS

func NewDummyECS(ops ...Option) (*DummyECS, error)

NewDummyECS create a mock of the ECS metadata API.

func (*DummyECS) ServeHTTP

func (d *DummyECS) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is used to handle HTTP requests.

func (*DummyECS) Start

func (d *DummyECS) Start() (*httptest.Server, int, error)

Start starts the HTTP server

type Option

type Option func(*DummyECS)

Option represents an option used to create a new mock of the ECS metadata server.

func FileHandlerOption

func FileHandlerOption(pattern, testDataFile string) Option

FileHandlerOption allows returning the content of a file to requests matching a pattern.

func RawHandlerOption

func RawHandlerOption(pattern, rawResponse string) Option

RawHandlerOption allows returning the specified string to requests matching a pattern.

Jump to

Keyboard shortcuts

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