testutil

package
v2.41.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoBegin

func GoBegin[TResult any](action func() TResult) chan TResult

func GoBegin2

func GoBegin2[TResult1 any, TResult2 any](action func() (TResult1, TResult2)) chan Pair[TResult1, TResult2]

func ReceivePair

func ReceivePair[T1 any, T2 any](receiver chan Pair[T1, T2]) (T1, T2)

Types

type MockHttpServer

type MockHttpServer struct {
	// when the client issues a request, we receive it here
	Request chan *http.Request
	// when we want to respond back to the client, we send it here
	Response chan responseOrError
	// contains filtered or unexported fields
}

func NewMockHttpServer

func NewMockHttpServer() *MockHttpServer

func (*MockHttpServer) Do

func (m *MockHttpServer) Do(req *http.Request) (*http.Response, error)

func (*MockHttpServer) ExpectRequest

func (m *MockHttpServer) ExpectRequest(t *testing.T, method string, pathAndQuery string) *RequestWrapper

func (*MockHttpServer) GetPendingMessageCount

func (m *MockHttpServer) GetPendingMessageCount() int

func (*MockHttpServer) ReceiveRequest

func (m *MockHttpServer) ReceiveRequest() *http.Request

func (*MockHttpServer) Respond

func (m *MockHttpServer) Respond(response *http.Response, err error)

func (*MockHttpServer) Sling

func (m *MockHttpServer) Sling() *sling.Sling

type Pair

type Pair[T1 any, T2 any] struct {
	Item1 T1
	Item2 T2
}

type RequestWrapper

type RequestWrapper struct {
	// in case you need it
	Request *http.Request
	Server  *MockHttpServer
}

func (*RequestWrapper) RespondWith

func (r *RequestWrapper) RespondWith(responseObject any)

func (*RequestWrapper) RespondWithText

func (r *RequestWrapper) RespondWithText(body string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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