homepage

package
v1.52.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HomepagePath is the string value which contains the URI to get the homepage's data.json
	HomepagePath = "/"

	// ImageVariant is the image variant to use for the homepage
	ImageVariant = "original"
)

Variables

This section is empty.

Functions

func Handler

func Handler(cfg *config.Config, homepageClient Clienter, rend RenderClient) http.HandlerFunc

Handler handles requests to homepage endpoint

Types

type Clienter added in v1.27.0

type Clienter interface {
	AddNavigationCache(ctx context.Context, updateInterval time.Duration) error
	GetHomePage(ctx context.Context, userAccessToken, collectionID, lang string) (*model.HomepageData, error)
	GetNavigationData(ctx context.Context, lang string) (*topicModel.Navigation, error)
	Close()
	StartBackgroundUpdate(ctx context.Context, errorChannel chan error)
}

Clienter is an interface with methods required for Homepage client

func NewPublishingClient added in v1.27.0

func NewPublishingClient(clients *Clients, languages []string) Clienter

func NewWebClient added in v1.27.0

func NewWebClient(ctx context.Context, clients *Clients, updateInterval time.Duration, languages []string) (Clienter, error)

type ClienterMock added in v1.29.0

type ClienterMock struct {
	// AddNavigationCacheFunc mocks the AddNavigationCache method.
	AddNavigationCacheFunc func(ctx context.Context, updateInterval time.Duration) error

	// CloseFunc mocks the Close method.
	CloseFunc func()

	// GetHomePageFunc mocks the GetHomePage method.
	GetHomePageFunc func(ctx context.Context, userAccessToken string, collectionID string, lang string) (*model.HomepageData, error)

	// GetNavigationDataFunc mocks the GetNavigationData method.
	GetNavigationDataFunc func(ctx context.Context, lang string) (*models.Navigation, error)

	// StartBackgroundUpdateFunc mocks the StartBackgroundUpdate method.
	StartBackgroundUpdateFunc func(ctx context.Context, errorChannel chan error)
	// contains filtered or unexported fields
}

ClienterMock is a mock implementation of Clienter.

    func TestSomethingThatUsesClienter(t *testing.T) {

        // make and configure a mocked Clienter
        mockedClienter := &ClienterMock{
            AddNavigationCacheFunc: func(ctx context.Context, updateInterval time.Duration) error {
	               panic("mock out the AddNavigationCache method")
            },
            CloseFunc: func()  {
	               panic("mock out the Close method")
            },
            GetHomePageFunc: func(ctx context.Context, userAccessToken string, collectionID string, lang string) (*model.HomepageData, error) {
	               panic("mock out the GetHomePage method")
            },
            GetNavigationDataFunc: func(ctx context.Context, lang string) (*models.Navigation, error) {
	               panic("mock out the GetNavigationData method")
            },
            StartBackgroundUpdateFunc: func(ctx context.Context, errorChannel chan error)  {
	               panic("mock out the StartBackgroundUpdate method")
            },
        }

        // use mockedClienter in code that requires Clienter
        // and then make assertions.

    }

func (*ClienterMock) AddNavigationCache added in v1.29.0

func (mock *ClienterMock) AddNavigationCache(ctx context.Context, updateInterval time.Duration) error

AddNavigationCache calls AddNavigationCacheFunc.

func (*ClienterMock) AddNavigationCacheCalls added in v1.29.0

func (mock *ClienterMock) AddNavigationCacheCalls() []struct {
	Ctx            context.Context
	UpdateInterval time.Duration
}

AddNavigationCacheCalls gets all the calls that were made to AddNavigationCache. Check the length with:

len(mockedClienter.AddNavigationCacheCalls())

func (*ClienterMock) Close added in v1.29.0

func (mock *ClienterMock) Close()

Close calls CloseFunc.

func (*ClienterMock) CloseCalls added in v1.29.0

func (mock *ClienterMock) CloseCalls() []struct {
}

CloseCalls gets all the calls that were made to Close. Check the length with:

len(mockedClienter.CloseCalls())

func (*ClienterMock) GetHomePage added in v1.29.0

func (mock *ClienterMock) GetHomePage(ctx context.Context, userAccessToken string, collectionID string, lang string) (*model.HomepageData, error)

GetHomePage calls GetHomePageFunc.

func (*ClienterMock) GetHomePageCalls added in v1.29.0

func (mock *ClienterMock) GetHomePageCalls() []struct {
	Ctx             context.Context
	UserAccessToken string
	CollectionID    string
	Lang            string
}

GetHomePageCalls gets all the calls that were made to GetHomePage. Check the length with:

len(mockedClienter.GetHomePageCalls())

func (*ClienterMock) GetNavigationData added in v1.29.0

func (mock *ClienterMock) GetNavigationData(ctx context.Context, lang string) (*models.Navigation, error)

GetNavigationData calls GetNavigationDataFunc.

func (*ClienterMock) GetNavigationDataCalls added in v1.29.0

func (mock *ClienterMock) GetNavigationDataCalls() []struct {
	Ctx  context.Context
	Lang string
}

GetNavigationDataCalls gets all the calls that were made to GetNavigationData. Check the length with:

len(mockedClienter.GetNavigationDataCalls())

func (*ClienterMock) StartBackgroundUpdate added in v1.29.0

func (mock *ClienterMock) StartBackgroundUpdate(ctx context.Context, errorChannel chan error)

StartBackgroundUpdate calls StartBackgroundUpdateFunc.

func (*ClienterMock) StartBackgroundUpdateCalls added in v1.29.0

func (mock *ClienterMock) StartBackgroundUpdateCalls() []struct {
	Ctx          context.Context
	ErrorChannel chan error
}

StartBackgroundUpdateCalls gets all the calls that were made to StartBackgroundUpdate. Check the length with:

len(mockedClienter.StartBackgroundUpdateCalls())

type Clients added in v1.11.0

type Clients struct {
	Zebedee  ZebedeeClient
	ImageAPI ImageClient
	Renderer RenderClient
	Topic    topicCli.Clienter
}

Clients contains all the required Clients for frontend homepage controller

type ImageClient added in v1.6.0

type ImageClient interface {
	GetDownloadVariant(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, imageID, variant string) (m image.ImageDownload, err error)
	Checker(ctx context.Context, check *health.CheckState) error
}

ImageClient is an interface with methods required for the Image API service client

type ImageClientMock added in v1.15.0

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

	// GetDownloadVariantFunc mocks the GetDownloadVariant method.
	GetDownloadVariantFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, imageID string, variant string) (image.ImageDownload, error)
	// contains filtered or unexported fields
}

ImageClientMock is a mock implementation of ImageClient.

    func TestSomethingThatUsesImageClient(t *testing.T) {

        // make and configure a mocked ImageClient
        mockedImageClient := &ImageClientMock{
            CheckerFunc: func(ctx context.Context, check *healthcheck.CheckState) error {
	               panic("mock out the Checker method")
            },
            GetDownloadVariantFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, imageID string, variant string) (image.ImageDownload, error) {
	               panic("mock out the GetDownloadVariant method")
            },
        }

        // use mockedImageClient in code that requires ImageClient
        // and then make assertions.

    }

func (*ImageClientMock) Checker added in v1.15.0

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

Checker calls CheckerFunc.

func (*ImageClientMock) CheckerCalls added in v1.15.0

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

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

len(mockedImageClient.CheckerCalls())

func (*ImageClientMock) GetDownloadVariant added in v1.15.0

func (mock *ImageClientMock) GetDownloadVariant(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, imageID string, variant string) (image.ImageDownload, error)

GetDownloadVariant calls GetDownloadVariantFunc.

func (*ImageClientMock) GetDownloadVariantCalls added in v1.15.0

func (mock *ImageClientMock) GetDownloadVariantCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	ImageID          string
	Variant          string
}

GetDownloadVariantCalls gets all the calls that were made to GetDownloadVariant. Check the length with:

len(mockedImageClient.GetDownloadVariantCalls())

type MainFigure added in v1.1.0

type MainFigure struct {
	// contains filtered or unexported fields
}

type PublishingClient added in v1.27.0

type PublishingClient struct {
	Updater
	// contains filtered or unexported fields
}

func (*PublishingClient) AddNavigationCache added in v1.27.0

func (hpc *PublishingClient) AddNavigationCache(ctx context.Context, updateInterval time.Duration) error

func (*PublishingClient) Close added in v1.27.0

func (hpc *PublishingClient) Close()

func (*PublishingClient) GetHomePage added in v1.27.0

func (hpc *PublishingClient) GetHomePage(ctx context.Context, userAccessToken, collectionID, lang string) (*model.HomepageData, error)

func (*PublishingClient) GetNavigationData added in v1.27.0

func (hpc *PublishingClient) GetNavigationData(ctx context.Context, lang string) (*topicModel.Navigation, error)

func (*PublishingClient) StartBackgroundUpdate added in v1.27.0

func (hpc *PublishingClient) StartBackgroundUpdate(ctx context.Context, errorChannel chan error)

type RenderClient added in v1.1.0

type RenderClient interface {
	BuildPage(w io.Writer, pageModel interface{}, templateName string)
	NewBasePageModel() rendModel.Page
}

RenderClient is an interface with methods required for rendering a template from a page model

type RenderClientMock added in v1.15.0

type RenderClientMock struct {
	// BuildPageFunc mocks the BuildPage method.
	BuildPageFunc func(w io.Writer, pageModel interface{}, templateName string)

	// NewBasePageModelFunc mocks the NewBasePageModel method.
	NewBasePageModelFunc func() model.Page
	// 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{
            BuildPageFunc: func(w io.Writer, pageModel interface{}, templateName string)  {
	               panic("mock out the BuildPage method")
            },
            NewBasePageModelFunc: func() model.Page {
	               panic("mock out the NewBasePageModel method")
            },
        }

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

    }

func (*RenderClientMock) BuildPage added in v1.15.0

func (mock *RenderClientMock) BuildPage(w io.Writer, pageModel interface{}, templateName string)

BuildPage calls BuildPageFunc.

func (*RenderClientMock) BuildPageCalls added in v1.15.0

func (mock *RenderClientMock) BuildPageCalls() []struct {
	W            io.Writer
	PageModel    interface{}
	TemplateName string
}

BuildPageCalls gets all the calls that were made to BuildPage. Check the length with:

len(mockedRenderClient.BuildPageCalls())

func (*RenderClientMock) NewBasePageModel added in v1.15.0

func (mock *RenderClientMock) NewBasePageModel() model.Page

NewBasePageModel calls NewBasePageModelFunc.

func (*RenderClientMock) NewBasePageModelCalls added in v1.15.0

func (mock *RenderClientMock) NewBasePageModelCalls() []struct {
}

NewBasePageModelCalls gets all the calls that were made to NewBasePageModel. Check the length with:

len(mockedRenderClient.NewBasePageModelCalls())

type Updater added in v1.27.0

type Updater struct {
	// contains filtered or unexported fields
}

func (*Updater) GetHomePageUpdateFor added in v1.27.0

func (hu *Updater) GetHomePageUpdateFor(ctx context.Context, userAccessToken, collectionID, lang string) func() (*model.HomepageData, error)

func (*Updater) UpdateNavigationData added in v1.27.0

func (hu *Updater) UpdateNavigationData(ctx context.Context, lang string) func() *topicModel.Navigation

type WebClient added in v1.27.0

type WebClient struct {
	Updater
	// contains filtered or unexported fields
}

func (*WebClient) AddNavigationCache added in v1.27.0

func (hwc *WebClient) AddNavigationCache(ctx context.Context, updateInterval time.Duration) error

func (*WebClient) Close added in v1.27.0

func (hwc *WebClient) Close()

func (*WebClient) GetHomePage added in v1.27.0

func (hwc *WebClient) GetHomePage(ctx context.Context, userAccessToken, collectionID, lang string) (*model.HomepageData, error)

func (*WebClient) GetNavigationData added in v1.27.0

func (hwc *WebClient) GetNavigationData(ctx context.Context, lang string) (*topicModel.Navigation, error)

func (*WebClient) StartBackgroundUpdate added in v1.27.0

func (hwc *WebClient) StartBackgroundUpdate(ctx context.Context, errorChannel chan error)

type ZebedeeClient added in v1.1.0

type ZebedeeClient interface {
	GetTimeseriesMainFigure(ctx context.Context, userAuthToken, collectionID, lang, uri string) (m zebedee.TimeseriesMainFigure, err error)
	GetHomepageContent(ctx context.Context, userAccessToken, collectionID, lang, path string) (m zebedee.HomepageContent, err error)
	Checker(ctx context.Context, check *health.CheckState) error
}

ZebedeeClient is an interface with methods required for a zebedee client

type ZebedeeClientMock added in v1.15.0

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

	// GetHomepageContentFunc mocks the GetHomepageContent method.
	GetHomepageContentFunc func(ctx context.Context, userAccessToken string, collectionID string, lang string, path string) (zebedee.HomepageContent, error)

	// GetTimeseriesMainFigureFunc mocks the GetTimeseriesMainFigure method.
	GetTimeseriesMainFigureFunc func(ctx context.Context, userAuthToken string, collectionID string, lang string, uri string) (zebedee.TimeseriesMainFigure, 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")
            },
            GetHomepageContentFunc: func(ctx context.Context, userAccessToken string, collectionID string, lang string, path string) (zebedee.HomepageContent, error) {
	               panic("mock out the GetHomepageContent method")
            },
            GetTimeseriesMainFigureFunc: func(ctx context.Context, userAuthToken string, collectionID string, lang string, uri string) (zebedee.TimeseriesMainFigure, error) {
	               panic("mock out the GetTimeseriesMainFigure method")
            },
        }

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

    }

func (*ZebedeeClientMock) Checker added in v1.15.0

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

Checker calls CheckerFunc.

func (*ZebedeeClientMock) CheckerCalls added in v1.15.0

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) GetHomepageContent added in v1.15.0

func (mock *ZebedeeClientMock) GetHomepageContent(ctx context.Context, userAccessToken string, collectionID string, lang string, path string) (zebedee.HomepageContent, error)

GetHomepageContent calls GetHomepageContentFunc.

func (*ZebedeeClientMock) GetHomepageContentCalls added in v1.15.0

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

GetHomepageContentCalls gets all the calls that were made to GetHomepageContent. Check the length with:

len(mockedZebedeeClient.GetHomepageContentCalls())

func (*ZebedeeClientMock) GetTimeseriesMainFigure added in v1.15.0

func (mock *ZebedeeClientMock) GetTimeseriesMainFigure(ctx context.Context, userAuthToken string, collectionID string, lang string, uri string) (zebedee.TimeseriesMainFigure, error)

GetTimeseriesMainFigure calls GetTimeseriesMainFigureFunc.

func (*ZebedeeClientMock) GetTimeseriesMainFigureCalls added in v1.15.0

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

GetTimeseriesMainFigureCalls gets all the calls that were made to GetTimeseriesMainFigure. Check the length with:

len(mockedZebedeeClient.GetTimeseriesMainFigureCalls())

Jump to

Keyboard shortcuts

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