mock

package
v0.0.0-...-c20d51c Latest Latest
Warning

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

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

Documentation

Overview

Package mock provides a mock client to be used in testing. It can allow tests using the Client or Factory interfaces to be tested without making real network connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockRobotsResponse

func MockRobotsResponse() *http.Response

func ResponseFromString

func ResponseFromString(s string) *http.Response

Types

type MockClient

type MockClient struct {
	ForeverResponse *http.Response
	NextResponse    *http.Response
	Requests        []*url.URL
	Redir           *url.URL
	CheckRedirect   func(*http.Request, []*http.Request) error
}

func (*MockClient) Request

func (c *MockClient) Request(u *url.URL, host, method string, header http.Header) (*http.Response, error)

func (*MockClient) RequestURL

func (c *MockClient) RequestURL(u *url.URL) (*http.Response, error)

func (*MockClient) SetCheckRedirect

func (c *MockClient) SetCheckRedirect(f func(*http.Request, []*http.Request) error)

type MockClientFactory

type MockClientFactory struct {
	ForeverClient *MockClient
	NextClient    *MockClient
}

func (*MockClientFactory) Get

func (f *MockClientFactory) Get() client.Client

Jump to

Keyboard shortcuts

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