handlers

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MIT Imports: 12 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(cfg *config.Config, rendC RenderClient, searchC SearchClient) http.HandlerFunc

Read Handler

Types

type ClientError

type ClientError interface {
	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 searchC.Response, err error)
	GetDepartments(ctx context.Context, query url.Values) (d searchCli.Department, err error)
}

SearchClient is an interface with methods required for a search client

type SearchClientMock added in v0.2.0

type SearchClientMock struct {
	// GetDepartmentsFunc mocks the GetDepartments method.
	GetDepartmentsFunc func(ctx context.Context, query url.Values) (search.Department, error)

	// 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{
            GetDepartmentsFunc: func(ctx context.Context, query url.Values) (search.Department, error) {
	               panic("mock out the GetDepartments method")
            },
            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) GetDepartments added in v0.7.0

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

GetDepartments calls GetDepartmentsFunc.

func (*SearchClientMock) GetDepartmentsCalls added in v0.7.0

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

GetDepartmentsCalls gets all the calls that were made to GetDepartments. Check the length with:

len(mockedSearchClient.GetDepartmentsCalls())

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