Help us shape the future of Go! Take the 2026 Go Developer Survey

frontendtest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package frontendtest supplies configurable fakes for protocol implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	BuildFunc func(context.Context, frontend.CapabilityRequest) (frontend.CapabilityResult, error)
}

Capabilities is a configurable fake for the host capability provider.

func (Capabilities) Build

type Experience

type Experience struct {
	CollectionsFunc          func(context.Context, *core.Viewer, core.Device, frontend.CollectionQuery) (frontend.CollectionPage, error)
	NotInterestedFunc        func(context.Context, *core.Viewer, core.Device, frontend.PageQuery) (frontend.NotInterestedPage, error)
	NotInterestedItemFunc    func(context.Context, *core.Viewer, core.Device, core.RatingKey) (frontend.NotInterestedEntry, error)
	ResolveExternalFunc      func(context.Context, *core.Viewer, core.Device, frontend.ExternalRequest) (core.RatingKey, error)
	ResolveEventSubjectFunc  func(context.Context, *core.Viewer, core.Device, frontend.FavoriteRef) (frontend.ResolvedEventSubject, error)
	SetNotInterestedFunc     func(context.Context, *core.Viewer, core.RatingKey, bool) error
	NamedFacetIDsFunc        func(context.Context, *core.Viewer, core.Device, core.RatingKey, string, []string) (map[string]string, error)
	PersonFacetIDsFunc       func(context.Context, *core.Viewer, core.Device, core.RatingKey, []int64) (map[int64]string, error)
	ResolveFacetFunc         func(context.Context, *core.Viewer, core.Device, string, string, string) (core.FacetValue, error)
	SetLikesFunc             func(context.Context, *core.Viewer, core.RatingKey, *bool) error
	SetEntityFavoriteFunc    func(context.Context, *core.Viewer, frontend.FavoriteRef, bool) error
	EntityFavoritesFunc      func(context.Context, *core.Viewer, []frontend.FavoriteRef) (map[frontend.FavoriteRef]bool, error)
	SimilarFunc              func(context.Context, *core.Viewer, core.Device, core.RatingKey, frontend.ItemQuery) (frontend.SearchPage, error)
	AncestorsFunc            func(context.Context, *core.Viewer, core.Device, core.RatingKey) ([]core.Title, error)
	FacetsFunc               func(context.Context, *core.Viewer, core.Device, string, string) ([]core.FacetValue, error)
	LibraryItemsFunc         func(context.Context, *core.Viewer, core.Device, string, frontend.ItemQuery) (core.Page, error)
	LibraryCountFunc         func(context.Context, *core.Viewer, string) (int, error)
	SetPlayedFunc            func(context.Context, *core.Viewer, core.RatingKey) error
	SetUnplayedFunc          func(context.Context, *core.Viewer, core.RatingKey) error
	SetWatchlistFunc         func(context.Context, *core.Viewer, core.RatingKey, bool) error
	SetFavoriteFunc          func(context.Context, *core.Viewer, core.RatingKey, bool) error
	SetRatingFunc            func(context.Context, *core.Viewer, core.RatingKey, float64) error
	RemoveFromContinueFunc   func(context.Context, *core.Viewer, core.RatingKey) error
	ReportRowInteractionFunc func(context.Context, frontend.RowInteraction) error
	ViewsFunc                func(context.Context, *core.Viewer) ([]frontend.View, error)
	RowsFunc                 func(context.Context, frontend.RowRequest) ([]frontend.Row, error)
	ItemFunc                 func(context.Context, frontend.ItemRequest) (frontend.ItemDetail, error)
	ItemArtworkFunc          func(context.Context, *core.Viewer, core.Device, core.RatingKey) ([]frontend.Image, bool, error)
	ChildrenFunc             func(context.Context, *core.Viewer, core.Device, core.RatingKey, frontend.ItemQuery) (core.Page, error)
	SearchFunc               func(context.Context, *core.Viewer, core.Device, string, frontend.ItemQuery) (frontend.SearchPage, error)
	UserDataFunc             func(context.Context, *core.Viewer, []core.RatingKey) (map[core.RatingKey]core.WatchStatus, error)
}

Experience implements frontend.Experience with optional function hooks.

func (Experience) Ancestors

func (f Experience) Ancestors(c context.Context, v *core.Viewer, d core.Device, k core.RatingKey) ([]core.Title, error)

func (Experience) Children

func (Experience) EntityFavorites

func (f Experience) EntityFavorites(c context.Context, v *core.Viewer, refs []frontend.FavoriteRef) (map[frontend.FavoriteRef]bool, error)

func (Experience) Facets

func (f Experience) Facets(c context.Context, v *core.Viewer, d core.Device, id, name string) ([]core.FacetValue, error)

func (Experience) Item

func (Experience) ItemArtwork

func (f Experience) ItemArtwork(c context.Context, v *core.Viewer, d core.Device, k core.RatingKey) ([]frontend.Image, bool, error)

func (Experience) LibraryCount

func (f Experience) LibraryCount(c context.Context, v *core.Viewer, id string) (int, error)

func (Experience) LibraryItems

func (f Experience) LibraryItems(c context.Context, v *core.Viewer, d core.Device, id string, q frontend.ItemQuery) (core.Page, error)

func (Experience) NamedFacetIDs

func (f Experience) NamedFacetIDs(c context.Context, v *core.Viewer, d core.Device, key core.RatingKey, kind string, names []string) (map[string]string, error)

func (Experience) NotInterested

func (Experience) NotInterestedItem

func (Experience) PersonFacetIDs

func (f Experience) PersonFacetIDs(c context.Context, v *core.Viewer, d core.Device, key core.RatingKey, ids []int64) (map[int64]string, error)

func (Experience) RemoveFromContinue

func (f Experience) RemoveFromContinue(c context.Context, v *core.Viewer, k core.RatingKey) error

func (Experience) ReportRowInteraction

func (f Experience) ReportRowInteraction(c context.Context, interaction frontend.RowInteraction) error

func (Experience) ResolveEventSubject

func (Experience) ResolveExternal

func (Experience) ResolveFacet

func (f Experience) ResolveFacet(c context.Context, v *core.Viewer, d core.Device, view, kind, id string) (core.FacetValue, error)

func (Experience) Rows

func (Experience) Search

func (Experience) SetEntityFavorite

func (f Experience) SetEntityFavorite(c context.Context, v *core.Viewer, ref frontend.FavoriteRef, on bool) error

func (Experience) SetFavorite

func (f Experience) SetFavorite(c context.Context, v *core.Viewer, k core.RatingKey, on bool) error

func (Experience) SetLikes

func (f Experience) SetLikes(c context.Context, v *core.Viewer, k core.RatingKey, likes *bool) error

func (Experience) SetNotInterested

func (f Experience) SetNotInterested(c context.Context, v *core.Viewer, k core.RatingKey, on bool) error

func (Experience) SetPlayed

func (f Experience) SetPlayed(c context.Context, v *core.Viewer, k core.RatingKey) error

func (Experience) SetRating

func (f Experience) SetRating(c context.Context, v *core.Viewer, k core.RatingKey, rating float64) error

func (Experience) SetUnplayed

func (f Experience) SetUnplayed(c context.Context, v *core.Viewer, k core.RatingKey) error

func (Experience) SetWatchlist

func (f Experience) SetWatchlist(c context.Context, v *core.Viewer, k core.RatingKey, on bool) error

func (Experience) Similar

func (Experience) UserData

func (Experience) Views

func (f Experience) Views(c context.Context, v *core.Viewer) ([]frontend.View, error)

type GrantDeviceIdentity

type GrantDeviceIdentity struct {
	Identity
	ResolveGrantDeviceFunc func(context.Context, string, string) (*core.Viewer, core.Device, time.Time, error)
}

GrantDeviceIdentity opts a fake identity into the optional grant-device API.

func (GrantDeviceIdentity) ResolveGrantDevice

func (f GrantDeviceIdentity) ResolveGrantDevice(ctx context.Context, credential, claim string) (*core.Viewer, core.Device, time.Time, error)

type Identity

type Identity struct {
	IssueRefreshFunc  func(context.Context, string, core.Device) (string, error)
	RefreshFunc       func(context.Context, string, core.Device) (string, string, error)
	ResolveFunc       func(context.Context, string) (*core.Viewer, error)
	ResolveDeviceFunc func(context.Context, string, core.Device) (*core.Viewer, time.Time, error)
	ViewerTimesFunc   func(context.Context, string, int64) (frontend.ViewerTimes, error)
	PublicViewersFunc func(context.Context) ([]frontend.PublicViewer, error)
	SignInFunc        func(context.Context, string, string, core.Device) (string, error)
	InitiateFunc      func(context.Context, core.Device) (string, string, error)
	StatusFunc        func(context.Context, string) (bool, error)
	DetailsFunc       func(context.Context, string) (frontend.QuickConnectDetails, error)
	PollFunc          func(context.Context, string) (string, error)
	ApproveFunc       func(context.Context, *core.Viewer, string) error
	RevokeFunc        func(context.Context, string) error
	SetupCompleteFunc func() bool
}

Identity implements a configurable surface-bound identity for protocol tests.

func (Identity) IssueRefresh

func (f Identity) IssueRefresh(ctx context.Context, token string, d core.Device) (string, error)

func (Identity) PublicViewers

func (f Identity) PublicViewers(ctx context.Context) ([]frontend.PublicViewer, error)

func (Identity) QuickConnectApprove

func (f Identity) QuickConnectApprove(ctx context.Context, viewer *core.Viewer, code string) error

func (Identity) QuickConnectDetails

func (f Identity) QuickConnectDetails(ctx context.Context, secret string) (frontend.QuickConnectDetails, error)

func (Identity) QuickConnectInitiate

func (f Identity) QuickConnectInitiate(ctx context.Context, d core.Device) (string, string, error)

func (Identity) QuickConnectPoll

func (f Identity) QuickConnectPoll(ctx context.Context, secret string) (string, error)

func (Identity) QuickConnectStatus

func (f Identity) QuickConnectStatus(ctx context.Context, secret string) (bool, error)

func (Identity) Refresh

func (f Identity) Refresh(ctx context.Context, token string, d core.Device) (string, string, error)

func (Identity) Resolve

func (f Identity) Resolve(ctx context.Context, credential string) (*core.Viewer, error)

func (Identity) ResolveDevice

func (f Identity) ResolveDevice(ctx context.Context, credential string, device core.Device) (*core.Viewer, time.Time, error)

func (Identity) Revoke

func (f Identity) Revoke(ctx context.Context, grant string) error

func (Identity) SetupComplete

func (f Identity) SetupComplete() bool

func (Identity) SignIn

func (f Identity) SignIn(ctx context.Context, user, password string, d core.Device) (string, error)

func (Identity) ViewerTimes

func (f Identity) ViewerTimes(ctx context.Context, credential string, viewerID int64) (frontend.ViewerTimes, error)

type ImageGrants

type ImageGrants struct {
	IssueFunc      func(context.Context, frontend.ImageGrantRequest) (string, error)
	IssueBatchFunc func(context.Context, frontend.ImageBatchRequest) ([]frontend.ImageBatchItem, error)
	RevokeFunc     func(context.Context, string, string) error
	ServeFunc      func(http.ResponseWriter, *http.Request, string)
}

ImageGrants provides optional hooks for scoped individual and batch grants.

func (ImageGrants) Issue

func (ImageGrants) IssueBatch

func (ImageGrants) Revoke

func (f ImageGrants) Revoke(ctx context.Context, credential, secret string) error

func (ImageGrants) Serve

func (f ImageGrants) Serve(w http.ResponseWriter, r *http.Request, secret string)

type LiveTV

type LiveTV struct {
	ChannelsFunc         func(context.Context, *core.Viewer) ([]frontend.LiveChannel, error)
	GuideFunc            func(context.Context, *core.Viewer, frontend.LiveGuideQuery) ([]frontend.LiveProgramme, error)
	ResolveChannelFunc   func(context.Context, *core.Viewer, string) (frontend.LiveChannel, error)
	ResolveProgrammeFunc func(context.Context, *core.Viewer, string, frontend.LiveGuideQuery) (frontend.LiveProgramme, error)
}

LiveTV is a configurable fake for viewer-scoped live television.

func (LiveTV) Channels

func (f LiveTV) Channels(ctx context.Context, v *core.Viewer) ([]frontend.LiveChannel, error)

func (LiveTV) Guide

func (LiveTV) ResolveChannelGUID

func (f LiveTV) ResolveChannelGUID(ctx context.Context, v *core.Viewer, id string) (frontend.LiveChannel, error)

func (LiveTV) ResolveProgrammeGUID

func (f LiveTV) ResolveProgrammeGUID(ctx context.Context, v *core.Viewer, id string, q frontend.LiveGuideQuery) (frontend.LiveProgramme, error)

type Preferences

type Preferences struct {
	GetFunc    func(context.Context, *core.Viewer, string, string) (json.RawMessage, error)
	PutFunc    func(context.Context, *core.Viewer, string, string, json.RawMessage) error
	DeleteFunc func(context.Context, *core.Viewer, string, string) error
}

Preferences is a configurable fake for protocol presentation state.

func (Preferences) Delete

func (f Preferences) Delete(ctx context.Context, v *core.Viewer, client, key string) error

func (Preferences) Get

func (f Preferences) Get(ctx context.Context, v *core.Viewer, client, key string) (json.RawMessage, error)

func (Preferences) Put

func (f Preferences) Put(ctx context.Context, v *core.Viewer, client, key string, data json.RawMessage) error

type Sessions

type Sessions struct {
	PlanFunc               func(context.Context, frontend.PlanRequest) (frontend.PlayPlan, error)
	OpenFunc               func(context.Context, frontend.OpenRequest) (frontend.Session, error)
	StartStreamFunc        func(context.Context, frontend.SessionAccess, string, frontend.StreamRequest) (string, error)
	SubtitleURLFunc        func(context.Context, frontend.SessionAccess, string, int, string) (string, error)
	MarkersFunc            func(context.Context, frontend.SessionAccess, string) (frontend.SessionMarkers, error)
	ServeMediaFunc         func(http.ResponseWriter, *http.Request)
	ReportSampleFunc       func(context.Context, frontend.SessionAccess, string, frontend.ProgressSample) (frontend.ReportOutcome, error)
	ReportFunc             func(context.Context, frontend.SessionAccess, string, frontend.Timeline) error
	ReportItemFunc         func(context.Context, frontend.SessionAccess, core.RatingKey, frontend.Timeline) error
	StopFunc               func(context.Context, frontend.SessionAccess, string) error
	CommandFunc            func(context.Context, *core.Viewer, string, frontend.Command) error
	UpdateCapabilitiesFunc func(context.Context, frontend.SessionAccess, frontend.SessionCapabilities) error
	CapabilitiesFunc       func(context.Context, frontend.SessionAccess) (frontend.SessionCapabilities, error)
	SessionsFunc           func(context.Context, frontend.SessionAccess) ([]frontend.Session, error)
	RecoverFunc            func(context.Context, string, string, time.Duration) error
	TranscodeForFunc       func(context.Context, string) (core.HLSSession, bool)
	EventsFunc             func(context.Context, frontend.EventScope) (<-chan frontend.Event, error)
}

Sessions implements frontend.Sessions with optional function hooks.

func (Sessions) Command

func (f Sessions) Command(c context.Context, actor *core.Viewer, id string, cmd frontend.Command) error

func (Sessions) Events

func (f Sessions) Events(c context.Context, s frontend.EventScope) (<-chan frontend.Event, error)

func (Sessions) Markers

func (Sessions) Open

func (Sessions) Plan

func (Sessions) Recover

func (f Sessions) Recover(c context.Context, id, url string, at time.Duration) error

func (Sessions) Report

func (Sessions) ReportItemProgress

func (f Sessions) ReportItemProgress(c context.Context, a frontend.SessionAccess, item core.RatingKey, t frontend.Timeline) error

func (Sessions) ReportSample

func (Sessions) ServeMedia

func (f Sessions) ServeMedia(w http.ResponseWriter, r *http.Request)

func (Sessions) Sessions

func (Sessions) StartStream

func (Sessions) Stop

func (Sessions) SubtitleURL

func (f Sessions) SubtitleURL(c context.Context, a frontend.SessionAccess, id string, index int, format string) (string, error)

func (Sessions) TranscodeFor

func (f Sessions) TranscodeFor(c context.Context, id string) (core.HLSSession, bool)

func (Sessions) UpdateCapabilities

type TrackPreferences

type TrackPreferences struct {
	GetFunc func(context.Context, *core.Viewer) (frontend.TrackPreferences, error)
	SetFunc func(context.Context, *core.Viewer, []string, string) error
}

TrackPreferences is a configurable fake for shared viewer track settings.

func (TrackPreferences) Get

func (TrackPreferences) SetSubtitle

func (f TrackPreferences) SetSubtitle(ctx context.Context, v *core.Viewer, languages []string, mode string) error

type VirtualPaths

type VirtualPaths struct {
	PathFunc  func(context.Context, *core.Viewer, core.Device, core.RatingKey) (string, error)
	PathsFunc func(context.Context, *core.Viewer, core.Device, []core.RatingKey) (map[core.RatingKey]string, error)
	BaseFunc  func(context.Context, *http.Request) (string, error)
}

VirtualPaths supplies configurable viewer-scoped virtual paths.

func (VirtualPaths) Base

func (f VirtualPaths) Base(ctx context.Context, r *http.Request) (string, error)

func (VirtualPaths) Path

func (VirtualPaths) Paths

func (f VirtualPaths) Paths(ctx context.Context, v *core.Viewer, d core.Device, keys []core.RatingKey) (map[core.RatingKey]string, error)

Jump to

Keyboard shortcuts

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