handlers

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read added in v0.2.0

func Read(rendC RenderClient, searchC SearchClient) http.HandlerFunc

Read Handler

Types

type ClientError

type ClientError interface {
	Error() string
	Code() int
}

ClientError is an interface that can be used to retrieve the status code if a client has errored

type RenderClient added in v0.2.0

type RenderClient interface {
	Do(string, []byte) ([]byte, error)
}

RenderClient is an interface with methods for require for rendering a template

type RenderClientMock added in v0.2.0

type RenderClientMock struct {
	// DoFunc mocks the Do method.
	DoFunc func(in1 string, in2 []byte) ([]byte, error)
	// contains filtered or unexported fields
}

RenderClientMock is a mock implementation of RenderClient.

    func TestSomethingThatUsesRenderClient(t *testing.T) {

        // make and configure a mocked RenderClient
        mockedRenderClient := &RenderClientMock{
            DoFunc: func(in1 string, in2 []byte) ([]byte, error) {
	               panic("mock out the Do method")
            },
        }

        // use mockedRenderClient in code that requires RenderClient
        // and then make assertions.

    }

func (*RenderClientMock) Do added in v0.2.0

func (mock *RenderClientMock) Do(in1 string, in2 []byte) ([]byte, error)

Do calls DoFunc.

func (*RenderClientMock) DoCalls added in v0.2.0

func (mock *RenderClientMock) DoCalls() []struct {
	In1 string
	In2 []byte
}

DoCalls gets all the calls that were made to Do. Check the length with:

len(mockedRenderClient.DoCalls())

type SearchClient added in v0.2.0

type SearchClient interface {
	GetSearch(ctx context.Context, query url.Values) (r search.Response, err error)
}

SearchClient is an interface with methods required for a search client

type SearchClientMock added in v0.2.0

type SearchClientMock struct {
	// GetSearchFunc mocks the GetSearch method.
	GetSearchFunc func(ctx context.Context, query url.Values) (search.Response, error)
	// contains filtered or unexported fields
}

SearchClientMock is a mock implementation of SearchClient.

    func TestSomethingThatUsesSearchClient(t *testing.T) {

        // make and configure a mocked SearchClient
        mockedSearchClient := &SearchClientMock{
            GetSearchFunc: func(ctx context.Context, query url.Values) (search.Response, error) {
	               panic("mock out the GetSearch method")
            },
        }

        // use mockedSearchClient in code that requires SearchClient
        // and then make assertions.

    }

func (*SearchClientMock) GetSearch added in v0.2.0

func (mock *SearchClientMock) GetSearch(ctx context.Context, query url.Values) (search.Response, error)

GetSearch calls GetSearchFunc.

func (*SearchClientMock) GetSearchCalls added in v0.2.0

func (mock *SearchClientMock) GetSearchCalls() []struct {
	Ctx   context.Context
	Query url.Values
}

GetSearchCalls gets all the calls that were made to GetSearch. Check the length with:

len(mockedSearchClient.GetSearchCalls())

Jump to

Keyboard shortcuts

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