api

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LegacyHandler

func LegacyHandler(ctx context.Context, zc ZebedeeClient) http.HandlerFunc

Types

type API

type API struct {
	Router *mux.Router
}

API provides a struct to wrap the api around

func Setup

func Setup(ctx context.Context, r *mux.Router, zc ZebedeeClient) *API

Setup function sets up the api and returns an api

type ZebedeeClient

type ZebedeeClient interface {
	GetRelease(ctx context.Context, userAccessToken, collectionID, lang, uri string) (zebedee.Release, error)
	Checker(ctx context.Context, check *healthcheck.CheckState) error
}

ZebedeeClient defines the required methods to talk to Zebedee

type ZebedeeClientMock

type ZebedeeClientMock struct {
	// CheckerFunc mocks the Checker method.
	CheckerFunc func(ctx context.Context, check *healthcheck.CheckState) error

	// GetReleaseFunc mocks the GetRelease method.
	GetReleaseFunc func(ctx context.Context, userAccessToken string, collectionID string, lang string, uri string) (zebedee.Release, error)
	// contains filtered or unexported fields
}

ZebedeeClientMock is a mock implementation of ZebedeeClient.

func TestSomethingThatUsesZebedeeClient(t *testing.T) {

	// make and configure a mocked ZebedeeClient
	mockedZebedeeClient := &ZebedeeClientMock{
		CheckerFunc: func(ctx context.Context, check *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		GetReleaseFunc: func(ctx context.Context, userAccessToken string, collectionID string, lang string, uri string) (zebedee.Release, error) {
			panic("mock out the GetRelease method")
		},
	}

	// use mockedZebedeeClient in code that requires ZebedeeClient
	// and then make assertions.

}

func (*ZebedeeClientMock) Checker

func (mock *ZebedeeClientMock) Checker(ctx context.Context, check *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*ZebedeeClientMock) CheckerCalls

func (mock *ZebedeeClientMock) CheckerCalls() []struct {
	Ctx   context.Context
	Check *healthcheck.CheckState
}

CheckerCalls gets all the calls that were made to Checker. Check the length with:

len(mockedZebedeeClient.CheckerCalls())

func (*ZebedeeClientMock) GetRelease

func (mock *ZebedeeClientMock) GetRelease(ctx context.Context, userAccessToken string, collectionID string, lang string, uri string) (zebedee.Release, error)

GetRelease calls GetReleaseFunc.

func (*ZebedeeClientMock) GetReleaseCalls

func (mock *ZebedeeClientMock) GetReleaseCalls() []struct {
	Ctx             context.Context
	UserAccessToken string
	CollectionID    string
	Lang            string
	URI             string
}

GetReleaseCalls gets all the calls that were made to GetRelease. Check the length with:

len(mockedZebedeeClient.GetReleaseCalls())

Jump to

Keyboard shortcuts

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