httptesting

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*httpclient.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(t *testing.T) *Client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, url string, parameters ...httpclient.RequestParameter) (*http.Response, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string, parameters ...httpclient.RequestParameter) (*http.Response, error)

func (*Client) HTTPMock

func (c *Client) HTTPMock() *httpmock.MockTransport

HTTPMock exposes the httpmock.MockTransport instance for advanced usage.

func (*Client) Head

func (c *Client) Head(ctx context.Context, url string, parameters ...httpclient.RequestParameter) (*http.Response, error)

func (*Client) NewJSONBodyMatcher

func (c *Client) NewJSONBodyMatcher(body string) httpmock.MatcherFunc

func (*Client) NewMockRequest

func (c *Client) NewMockRequest(method, url string, params ...httpclient.RequestParameter) *MockRequest

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, url string, body io.Reader, parameters ...httpclient.RequestParameter) (*http.Response, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, url string, body io.Reader, parameters ...httpclient.RequestParameter) (*http.Response, error)

func (*Client) WithBaseURL

func (c *Client) WithBaseURL(baseURL string) (*Client, error)

WithBaseURL sets the base URL setting for the underlying `httpclient.Client`.

func (*Client) WithDefaultHeaders

func (c *Client) WithDefaultHeaders(headers map[string]string) *Client

type HttpTestRequestParameter

type HttpTestRequestParameter httpclient.RequestParameter

type MockRequest

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

func (*MockRequest) Register

func (r *MockRequest) Register()

func (*MockRequest) RespondWithHeaders

func (r *MockRequest) RespondWithHeaders(respHeaders map[string]string) *MockRequest

RespondWithHeaders configures the response headers. It can be used multiple times in order to pass different headers. If the header key already exists it will be overwritten.

func (*MockRequest) RespondWithJSON

func (r *MockRequest) RespondWithJSON(statusCode int, body string) *MockRequest

RespondWithJSON will configure a JSON response with the given status code.

func (*MockRequest) Responder

func (r *MockRequest) Responder(resp httpmock.Responder) *MockRequest

Responder provides access to the current responder for inspection or direct operations.

func (*MockRequest) String

func (r *MockRequest) String() string

String provides a representation of the mock request. Only used for debugging purposes.

type MockResponse

type MockResponse httpmock.Responder

Jump to

Keyboard shortcuts

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