resttest

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2020 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package resttest provides utilities to test REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Headers          map[string]string
	ConcurrencyLevel int
	// contains filtered or unexported fields
}

Client keeps state of expectations.

func NewClient

func NewClient(baseURL string) *Client

NewClient creates client instance.

func (*Client) Concurrently

func (c *Client) Concurrently() *Client

Concurrently enables concurrent calls to idempotent endpoint.

func (*Client) ExpectOtherResponsesBody

func (c *Client) ExpectOtherResponsesBody(body []byte) error

ExpectOtherResponsesBody sets expectation for response body to be received one or more times during concurrent calling.

For example, it may describe "Not Found" response on multiple DELETE or "Conflict" response on multiple POST. Does not affect single (non-concurrent) calls.

func (*Client) ExpectOtherResponsesStatus

func (c *Client) ExpectOtherResponsesStatus(statusCode int) error

ExpectOtherResponsesStatus sets expectation for response status to be received one or more times during concurrent calling.

For example, it may describe "Not Found" response on multiple DELETE or "Conflict" response on multiple POST. Does not affect single (non-concurrent) calls.

func (*Client) ExpectResponseBody

func (c *Client) ExpectResponseBody(body []byte) error

ExpectResponseBody sets expectation for response body to be received.

In concurrent mode such response mush be met only once or for all calls.

func (*Client) ExpectResponseStatus

func (c *Client) ExpectResponseStatus(statusCode int) error

ExpectResponseStatus sets expected response status code.

func (*Client) Reset

func (c *Client) Reset() *Client

Reset deletes client state.

func (*Client) WithBody

func (c *Client) WithBody(body []byte) *Client

WithBody sets request body.

func (*Client) WithContentType

func (c *Client) WithContentType(contentType string) *Client

WithContentType sets request content type.

func (*Client) WithHeader

func (c *Client) WithHeader(key, value string) *Client

WithHeader sets request header.

func (*Client) WithMethod

func (c *Client) WithMethod(method string) *Client

WithMethod sets request HTTP method.

func (*Client) WithPath

func (c *Client) WithPath(path string) *Client

WithPath sets request URL path.

Jump to

Keyboard shortcuts

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