Documentation ¶
Index ¶
- Constants
- func GetIP(req *http.Request) string
- func SetTimeout(val time.Duration)
- func Timeout() time.Duration
- type Client
- type Expecter
- type Headers
- type HeadersStore
- type Method
- type MockedClient
- func (m *MockedClient) AllExpectationsDone() error
- func (m *MockedClient) Delete(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error)
- func (m *MockedClient) Do(ctx context.Context, method Method, url string, body []byte, headers Headers) (*http.Response, error)
- func (m *MockedClient) ExpectDelete(url string, body []byte, err error, response *http.Response, headers Headers)
- func (m *MockedClient) ExpectDo(url string, method Method, body []byte, err error, response *http.Response, ...)
- func (m *MockedClient) ExpectGet(url string, err error, response *http.Response, headers Headers)
- func (m *MockedClient) ExpectPatch(url string, body []byte, err error, response *http.Response, headers Headers)
- func (m *MockedClient) ExpectPost(url string, body []byte, err error, response *http.Response, headers Headers)
- func (m *MockedClient) ExpectPut(url string, body []byte, err error, response *http.Response, headers Headers)
- func (m *MockedClient) Get(ctx context.Context, url string, headers Headers) (*http.Response, error)
- func (m *MockedClient) Patch(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error)
- func (m *MockedClient) Post(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error)
- func (m *MockedClient) Put(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error)
- func (m *MockedClient) Reset()
- type Mocker
Constants ¶
const ( ERR_Unexpected_Method = "call %q expected method %q, got %q" ERR_Unexpected_Url = "call %q expected url %q, got %q" ERR_Unexpected_Data = "call %q expected data %v, got %v" ERR_Unexpected_Headers = "call %q expected headers %v, got %v" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface { Post(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error) Put(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error) Patch(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error) Delete(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error) Get(ctx context.Context, url string, headers Headers) (*http.Response, error) Do(ctx context.Context, method Method, url string, body []byte, headers Headers) (*http.Response, error) }
type Expecter ¶ added in v1.1.13
type Expecter interface { ExpectPost(url string, body []byte, err error, response *http.Response, headers Headers) ExpectPut(url string, body []byte, err error, response *http.Response, headers Headers) ExpectPatch(url string, body []byte, err error, response *http.Response, headers Headers) ExpectDelete(url string, body []byte, err error, response *http.Response, headers Headers) ExpectGet(url string, err error, response *http.Response, headers Headers) ExpectDo(url string, method Method, body []byte, err error, response *http.Response, headers Headers) AllExpectationsDone() error Reset() }
type Headers ¶ added in v1.1.14
type Headers interface { Set(key, value string) Keys() []string Get(key string) string Value() map[string]string }
func NewHeaders ¶ added in v1.1.14
type HeadersStore ¶ added in v1.1.14
func (HeadersStore) Get ¶ added in v1.1.14
func (h HeadersStore) Get(key string) string
func (HeadersStore) Keys ¶ added in v1.1.14
func (h HeadersStore) Keys() []string
func (HeadersStore) Set ¶ added in v1.1.14
func (h HeadersStore) Set(key, value string)
func (HeadersStore) Value ¶ added in v1.1.14
func (h HeadersStore) Value() map[string]string
type Method ¶ added in v1.1.13
type Method string
const ( MethodGet Method = http.MethodGet MethodPost Method = http.MethodPost MethodPut Method = http.MethodPut MethodPatch Method = http.MethodPatch MethodDelete Method = http.MethodDelete )
type MockedClient ¶ added in v1.1.13
type MockedClient struct {
// contains filtered or unexported fields
}
func (*MockedClient) AllExpectationsDone ¶ added in v1.1.13
func (m *MockedClient) AllExpectationsDone() error
Check if all expected calls were done
func (*MockedClient) Delete ¶ added in v1.1.13
func (m *MockedClient) Delete(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error)
Check if call of Post method was expected and returning expected response and error
func (*MockedClient) ExpectDelete ¶ added in v1.1.13
func (m *MockedClient) ExpectDelete(url string, body []byte, err error, response *http.Response, headers Headers)
Store expected call of Post method with expected data and error
func (*MockedClient) ExpectDo ¶ added in v1.1.13
func (m *MockedClient) ExpectDo(url string, method Method, body []byte, err error, response *http.Response, headers Headers)
Store expected call of Post method with expected data and error
func (*MockedClient) ExpectGet ¶ added in v1.1.13
Store expected call of Get method with expected data and error
func (*MockedClient) ExpectPatch ¶ added in v1.1.13
func (m *MockedClient) ExpectPatch(url string, body []byte, err error, response *http.Response, headers Headers)
Store expected call of Post method with expected data and error
func (*MockedClient) ExpectPost ¶ added in v1.1.13
func (m *MockedClient) ExpectPost(url string, body []byte, err error, response *http.Response, headers Headers)
Store expected call of Post method with expected data and error
func (*MockedClient) ExpectPut ¶ added in v1.1.13
func (m *MockedClient) ExpectPut(url string, body []byte, err error, response *http.Response, headers Headers)
Store expected call of Post method with expected data and error
func (*MockedClient) Get ¶ added in v1.1.13
func (m *MockedClient) Get(ctx context.Context, url string, headers Headers) (*http.Response, error)
Check if call of Get method was expected and returning expected response and error
func (*MockedClient) Patch ¶ added in v1.1.13
func (m *MockedClient) Patch(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error)
Check if call of Post method was expected and returning expected response and error
func (*MockedClient) Post ¶ added in v1.1.13
func (m *MockedClient) Post(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error)
Check if call of Post method was expected and returning expected response and error
func (*MockedClient) Put ¶ added in v1.1.13
func (m *MockedClient) Put(ctx context.Context, url string, body []byte, headers Headers) (*http.Response, error)
Check if call of Post method was expected and returning expected response and error
func (*MockedClient) Reset ¶ added in v1.1.13
func (m *MockedClient) Reset()
Reset all expected calls