Documentation
¶
Index ¶
- func CreateTestJSONRPCError(id any, code int, message string) []byte
- func CreateTestJSONRPCMessage(method string, params any) []byte
- func CreateTestJSONRPCResponse(id, result any) []byte
- type MockKodiClient
- func (m *MockKodiClient) APIRequest(method kodi.APIMethod, params any) (json.RawMessage, error)
- func (m *MockKodiClient) GetActivePlayers() ([]kodi.Player, error)
- func (m *MockKodiClient) GetAlbums() ([]kodi.Album, error)
- func (m *MockKodiClient) GetArtists() ([]kodi.Artist, error)
- func (m *MockKodiClient) GetEpisodes(tvShowID int) ([]kodi.Episode, error)
- func (m *MockKodiClient) GetMovies() ([]kodi.Movie, error)
- func (m *MockKodiClient) GetSongs() ([]kodi.Song, error)
- func (m *MockKodiClient) GetTVShows() ([]kodi.TVShow, error)
- func (m *MockKodiClient) GetURL() string
- func (m *MockKodiClient) LaunchAlbum(path string) error
- func (m *MockKodiClient) LaunchArtist(path string) error
- func (m *MockKodiClient) LaunchFile(path string) error
- func (m *MockKodiClient) LaunchMovie(path string) error
- func (m *MockKodiClient) LaunchSong(path string) error
- func (m *MockKodiClient) LaunchTVEpisode(path string) error
- func (m *MockKodiClient) LaunchTVShow(path string) error
- func (m *MockKodiClient) SetURL(url string)
- func (m *MockKodiClient) SetupBasicMock()
- func (m *MockKodiClient) Stop() error
- type MockMelody
- func (m *MockMelody) AddMockSession() *MockMelodySession
- func (m *MockMelody) Broadcast(msg []byte) error
- func (m *MockMelody) BroadcastFilter(msg []byte, filter func(*melody.Session) bool) error
- func (m *MockMelody) ClearSessions()
- func (m *MockMelody) Close() error
- func (m *MockMelody) GetSessionCount() int
- func (m *MockMelody) HandleConnect(handler func(*melody.Session))
- func (m *MockMelody) HandleDisconnect(handler func(*melody.Session))
- func (m *MockMelody) HandleError(handler func(*melody.Session, error))
- func (m *MockMelody) HandleMessage(handler func(*melody.Session, []byte))
- func (m *MockMelody) SetupBasicMock()
- func (m *MockMelody) SimulateConnect() *MockMelodySession
- func (m *MockMelody) SimulateDisconnect(sessionIndex int)
- func (m *MockMelody) SimulateMessage(sessionIndex int, message []byte)
- type MockMelodySession
- func (m *MockMelodySession) ClearMessages()
- func (m *MockMelodySession) Close() error
- func (m *MockMelodySession) CloseWithMsg(msg []byte) error
- func (m *MockMelodySession) Get(key string) (any, bool)
- func (m *MockMelodySession) GetBinaryMessages() [][]byte
- func (m *MockMelodySession) GetSentMessages() [][]byte
- func (m *MockMelodySession) IsClosed() bool
- func (m *MockMelodySession) LocalAddr() string
- func (m *MockMelodySession) MustGet(key string) any
- func (m *MockMelodySession) RemoteAddr() string
- func (m *MockMelodySession) Request() any
- func (m *MockMelodySession) Set(key string, value any)
- func (m *MockMelodySession) SetupBasicMock()
- func (m *MockMelodySession) Write(msg []byte) error
- func (m *MockMelodySession) WriteBinary(msg []byte) error
- type MockPlatform
- func (m *MockPlatform) ClearHistory()
- func (m *MockPlatform) ForwardCmd(env *platforms.CmdEnv) (platforms.CmdResult, error)
- func (m *MockPlatform) GamepadPress(button string) error
- func (m *MockPlatform) GetGamepadPresses() []string
- func (m *MockPlatform) GetKeyboardPresses() []string
- func (m *MockPlatform) GetLaunchedMedia() []string
- func (m *MockPlatform) GetLaunchedSystems() []string
- func (m *MockPlatform) ID() string
- func (m *MockPlatform) KeyboardPress(key string) error
- func (m *MockPlatform) LaunchMedia(cfg *config.Instance, path string) error
- func (m *MockPlatform) LaunchSystem(cfg *config.Instance, systemID string) error
- func (m *MockPlatform) Launchers(cfg *config.Instance) []platforms.Launcher
- func (m *MockPlatform) LookupMapping(token *tokens.Token) (string, bool)
- func (m *MockPlatform) NormalizePath(cfg *config.Instance, path string) string
- func (m *MockPlatform) PlayAudio(path string) error
- func (m *MockPlatform) RootDirs(cfg *config.Instance) []string
- func (m *MockPlatform) ScanHook(token *tokens.Token) error
- func (m *MockPlatform) Settings() platforms.Settings
- func (m *MockPlatform) SetupBasicMock()
- func (m *MockPlatform) ShowLoader(cfg *config.Instance, args widgetmodels.NoticeArgs) (func() error, error)
- func (m *MockPlatform) ShowNotice(cfg *config.Instance, args widgetmodels.NoticeArgs) (func() error, time.Duration, error)
- func (m *MockPlatform) ShowPicker(cfg *config.Instance, args widgetmodels.PickerArgs) error
- func (m *MockPlatform) StartPost(cfg *config.Instance, getActiveMedia func() *models.ActiveMedia, ...) error
- func (m *MockPlatform) StartPre(cfg *config.Instance) error
- func (m *MockPlatform) Stop() error
- func (m *MockPlatform) StopActiveLauncher() error
- func (m *MockPlatform) SupportedReaders(cfg *config.Instance) []readers.Reader
- type MockReader
- func (m *MockReader) CancelWrite()
- func (m *MockReader) Capabilities() []readers.Capability
- func (m *MockReader) Close() error
- func (m *MockReader) Connected() bool
- func (m *MockReader) Detect(devices []string) string
- func (m *MockReader) Device() string
- func (m *MockReader) IDs() []string
- func (m *MockReader) Info() string
- func (m *MockReader) Metadata() readers.DriverMetadata
- func (m *MockReader) OnMediaChange(media *models.ActiveMedia) error
- func (m *MockReader) Open(readerConfig config.ReadersConnect, scanChan chan<- readers.Scan) error
- func (m *MockReader) SetupBasicMock()
- func (*MockReader) SimulateError(scanChan chan<- readers.Scan, err error, source string)
- func (*MockReader) SimulateTokenScan(scanChan chan<- readers.Scan, token *tokens.Token, source string)
- func (m *MockReader) Write(data string) (*tokens.Token, error)
- type WebSocketTestMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTestJSONRPCError ¶
CreateTestJSONRPCError creates a test JSON-RPC error response
func CreateTestJSONRPCMessage ¶
CreateTestJSONRPCMessage creates a test JSON-RPC message
func CreateTestJSONRPCResponse ¶
CreateTestJSONRPCResponse creates a test JSON-RPC response
Types ¶
type MockKodiClient ¶
MockKodiClient is a mock implementation of the KodiClient interface for use in tests. It provides all the standard testify/mock functionality.
func NewMockKodiClient ¶
func NewMockKodiClient() *MockKodiClient
NewMockKodiClient creates a new mock Kodi client with basic setup
func (*MockKodiClient) APIRequest ¶
func (m *MockKodiClient) APIRequest(method kodi.APIMethod, params any) (json.RawMessage, error)
APIRequest mocks making a raw JSON-RPC request to Kodi API
func (*MockKodiClient) GetActivePlayers ¶
func (m *MockKodiClient) GetActivePlayers() ([]kodi.Player, error)
GetActivePlayers mocks retrieving all active players in Kodi
func (*MockKodiClient) GetAlbums ¶
func (m *MockKodiClient) GetAlbums() ([]kodi.Album, error)
GetAlbums mocks retrieving all albums from Kodi's library
func (*MockKodiClient) GetArtists ¶
func (m *MockKodiClient) GetArtists() ([]kodi.Artist, error)
GetArtists mocks retrieving all artists from Kodi's library
func (*MockKodiClient) GetEpisodes ¶
func (m *MockKodiClient) GetEpisodes(tvShowID int) ([]kodi.Episode, error)
GetEpisodes mocks retrieving all episodes for a specific TV show from Kodi's library
func (*MockKodiClient) GetMovies ¶
func (m *MockKodiClient) GetMovies() ([]kodi.Movie, error)
GetMovies mocks retrieving all movies from Kodi's library
func (*MockKodiClient) GetSongs ¶
func (m *MockKodiClient) GetSongs() ([]kodi.Song, error)
GetSongs mocks retrieving all songs from Kodi's library
func (*MockKodiClient) GetTVShows ¶
func (m *MockKodiClient) GetTVShows() ([]kodi.TVShow, error)
GetTVShows mocks retrieving all TV shows from Kodi's library
func (*MockKodiClient) GetURL ¶
func (m *MockKodiClient) GetURL() string
GetURL mocks returning the current Kodi API URL
func (*MockKodiClient) LaunchAlbum ¶
func (m *MockKodiClient) LaunchAlbum(path string) error
LaunchAlbum mocks launching an album in Kodi
func (*MockKodiClient) LaunchArtist ¶
func (m *MockKodiClient) LaunchArtist(path string) error
LaunchArtist mocks launching an artist in Kodi
func (*MockKodiClient) LaunchFile ¶
func (m *MockKodiClient) LaunchFile(path string) error
LaunchFile mocks launching a file in Kodi
func (*MockKodiClient) LaunchMovie ¶
func (m *MockKodiClient) LaunchMovie(path string) error
LaunchMovie mocks launching a movie in Kodi
func (*MockKodiClient) LaunchSong ¶
func (m *MockKodiClient) LaunchSong(path string) error
LaunchSong mocks launching a song in Kodi
func (*MockKodiClient) LaunchTVEpisode ¶
func (m *MockKodiClient) LaunchTVEpisode(path string) error
LaunchTVEpisode mocks launching a TV episode in Kodi
func (*MockKodiClient) LaunchTVShow ¶
func (m *MockKodiClient) LaunchTVShow(path string) error
LaunchTVShow mocks launching a TV show in Kodi
func (*MockKodiClient) SetURL ¶
func (m *MockKodiClient) SetURL(url string)
SetURL mocks setting the Kodi API URL
func (*MockKodiClient) SetupBasicMock ¶
func (m *MockKodiClient) SetupBasicMock()
SetupBasicMock configures the mock with common expectations for standard test scenarios
func (*MockKodiClient) Stop ¶
func (m *MockKodiClient) Stop() error
Stop mocks stopping all active players in Kodi
type MockMelody ¶
type MockMelody struct {
MessageHandler func(*melody.Session, []byte)
ConnectHandler func(*melody.Session)
DisconnectHandler func(*melody.Session)
ErrorHandler func(*melody.Session, error)
mock.Mock
Sessions []*MockMelodySession
// contains filtered or unexported fields
}
MockMelody mocks the melody.Melody WebSocket manager
func NewMockMelody ¶
func NewMockMelody() *MockMelody
NewMockMelody creates a new mock melody instance
func (*MockMelody) AddMockSession ¶
func (m *MockMelody) AddMockSession() *MockMelodySession
AddMockSession adds a mock session for testing
func (*MockMelody) Broadcast ¶
func (m *MockMelody) Broadcast(msg []byte) error
Broadcast mocks broadcasting a message to all sessions
func (*MockMelody) BroadcastFilter ¶
BroadcastFilter mocks broadcasting with a filter function
func (*MockMelody) ClearSessions ¶
func (m *MockMelody) ClearSessions()
ClearSessions removes all sessions
func (*MockMelody) GetSessionCount ¶
func (m *MockMelody) GetSessionCount() int
GetSessionCount returns the number of active sessions
func (*MockMelody) HandleConnect ¶
func (m *MockMelody) HandleConnect(handler func(*melody.Session))
HandleConnect mocks setting the connect handler
func (*MockMelody) HandleDisconnect ¶
func (m *MockMelody) HandleDisconnect(handler func(*melody.Session))
HandleDisconnect mocks setting the disconnect handler
func (*MockMelody) HandleError ¶
func (m *MockMelody) HandleError(handler func(*melody.Session, error))
HandleError mocks setting the error handler
func (*MockMelody) HandleMessage ¶
func (m *MockMelody) HandleMessage(handler func(*melody.Session, []byte))
HandleMessage mocks setting the message handler
func (*MockMelody) SetupBasicMock ¶
func (m *MockMelody) SetupBasicMock()
SetupBasicMock sets up basic expectations for the melody mock
func (*MockMelody) SimulateConnect ¶
func (m *MockMelody) SimulateConnect() *MockMelodySession
SimulateConnect simulates a new connection
func (*MockMelody) SimulateDisconnect ¶
func (m *MockMelody) SimulateDisconnect(sessionIndex int)
SimulateDisconnect simulates a disconnection
func (*MockMelody) SimulateMessage ¶
func (m *MockMelody) SimulateMessage(sessionIndex int, message []byte)
SimulateMessage simulates receiving a message on a session
type MockMelodySession ¶
type MockMelodySession struct {
Keys map[string]any
mock.Mock
CloseReason string
SentMessages [][]byte
BinaryMessages [][]byte
Closed bool
// contains filtered or unexported fields
}
MockMelodySession mocks a melody.Session for testing
func NewMockMelodySession ¶
func NewMockMelodySession() *MockMelodySession
NewMockMelodySession creates a new mock melody session
func (*MockMelodySession) ClearMessages ¶
func (m *MockMelodySession) ClearMessages()
ClearMessages clears all sent messages
func (*MockMelodySession) Close ¶
func (m *MockMelodySession) Close() error
Close mocks closing the WebSocket session
func (*MockMelodySession) CloseWithMsg ¶
func (m *MockMelodySession) CloseWithMsg(msg []byte) error
CloseWithMsg mocks closing the WebSocket session with a message
func (*MockMelodySession) Get ¶
func (m *MockMelodySession) Get(key string) (any, bool)
Get mocks getting a value by key
func (*MockMelodySession) GetBinaryMessages ¶
func (m *MockMelodySession) GetBinaryMessages() [][]byte
GetBinaryMessages returns all sent binary messages (thread-safe copy)
func (*MockMelodySession) GetSentMessages ¶
func (m *MockMelodySession) GetSentMessages() [][]byte
GetSentMessages returns all sent messages (thread-safe copy)
func (*MockMelodySession) IsClosed ¶
func (m *MockMelodySession) IsClosed() bool
IsClosed returns whether the session is closed
func (*MockMelodySession) LocalAddr ¶
func (m *MockMelodySession) LocalAddr() string
LocalAddr mocks getting the local address
func (*MockMelodySession) MustGet ¶
func (m *MockMelodySession) MustGet(key string) any
MustGet mocks getting a value by key (panics if not found)
func (*MockMelodySession) RemoteAddr ¶
func (m *MockMelodySession) RemoteAddr() string
RemoteAddr mocks getting the remote address
func (*MockMelodySession) Request ¶
func (m *MockMelodySession) Request() any
Request mocks getting the HTTP request
func (*MockMelodySession) Set ¶
func (m *MockMelodySession) Set(key string, value any)
Set mocks setting a key-value pair
func (*MockMelodySession) SetupBasicMock ¶
func (m *MockMelodySession) SetupBasicMock()
SetupBasicMock sets up basic mock expectations for common session operations
func (*MockMelodySession) Write ¶
func (m *MockMelodySession) Write(msg []byte) error
Write mocks writing a message to the WebSocket
func (*MockMelodySession) WriteBinary ¶
func (m *MockMelodySession) WriteBinary(msg []byte) error
WriteBinary mocks writing binary data to the WebSocket
type MockPlatform ¶
MockPlatform is a mock implementation of the Platform interface using testify/mock
func NewMockPlatform ¶
func NewMockPlatform() *MockPlatform
NewMockPlatform creates a new MockPlatform instance
func (*MockPlatform) ClearHistory ¶
func (m *MockPlatform) ClearHistory()
ClearHistory clears all tracked interactions
func (*MockPlatform) ForwardCmd ¶
ForwardCmd processes a platform-specific ZapScript command
func (*MockPlatform) GamepadPress ¶
func (m *MockPlatform) GamepadPress(button string) error
GamepadPress presses and then releases a single gamepad button
func (*MockPlatform) GetGamepadPresses ¶
func (m *MockPlatform) GetGamepadPresses() []string
GetGamepadPresses returns a slice of all gamepad buttons that were pressed
func (*MockPlatform) GetKeyboardPresses ¶
func (m *MockPlatform) GetKeyboardPresses() []string
GetKeyboardPresses returns a slice of all keyboard keys that were pressed
func (*MockPlatform) GetLaunchedMedia ¶
func (m *MockPlatform) GetLaunchedMedia() []string
GetLaunchedMedia returns a slice of all media paths that were launched
func (*MockPlatform) GetLaunchedSystems ¶
func (m *MockPlatform) GetLaunchedSystems() []string
GetLaunchedSystems returns a slice of all system IDs that were launched
func (*MockPlatform) ID ¶
func (m *MockPlatform) ID() string
ID returns the unique ID of this platform
func (*MockPlatform) KeyboardPress ¶
func (m *MockPlatform) KeyboardPress(key string) error
KeyboardPress presses and then releases a single keyboard button
func (*MockPlatform) LaunchMedia ¶
func (m *MockPlatform) LaunchMedia(cfg *config.Instance, path string) error
LaunchMedia launches some media by path and sets the active media if it was successful
func (*MockPlatform) LaunchSystem ¶
func (m *MockPlatform) LaunchSystem(cfg *config.Instance, systemID string) error
LaunchSystem launches a system by ID
func (*MockPlatform) Launchers ¶
func (m *MockPlatform) Launchers(cfg *config.Instance) []platforms.Launcher
Launchers is the complete list of all launchers available on this platform
func (*MockPlatform) LookupMapping ¶
func (m *MockPlatform) LookupMapping(token *tokens.Token) (string, bool)
LookupMapping is a platform-specific method of matching a token to a mapping
func (*MockPlatform) NormalizePath ¶
func (m *MockPlatform) NormalizePath(cfg *config.Instance, path string) string
NormalizePath converts a path to a normalized form for the platform
func (*MockPlatform) PlayAudio ¶
func (m *MockPlatform) PlayAudio(path string) error
PlayAudio plays an audio file at the given path
func (*MockPlatform) RootDirs ¶
func (m *MockPlatform) RootDirs(cfg *config.Instance) []string
RootDirs returns a list of root folders to scan for media files
func (*MockPlatform) ScanHook ¶
func (m *MockPlatform) ScanHook(token *tokens.Token) error
ScanHook is run immediately AFTER a successful scan, but BEFORE it is processed for launching
func (*MockPlatform) Settings ¶
func (m *MockPlatform) Settings() platforms.Settings
Settings returns all simple platform-specific settings such as paths
func (*MockPlatform) SetupBasicMock ¶
func (m *MockPlatform) SetupBasicMock()
SetupBasicMock configures the mock with typical default values for basic operations
func (*MockPlatform) ShowLoader ¶
func (m *MockPlatform) ShowLoader(cfg *config.Instance, args widgetmodels.NoticeArgs) (func() error, error)
ShowLoader displays a string on-screen alongside an animation
func (*MockPlatform) ShowNotice ¶
func (m *MockPlatform) ShowNotice(cfg *config.Instance, args widgetmodels.NoticeArgs, ) (func() error, time.Duration, error)
ShowNotice displays a string on-screen of the platform device
func (*MockPlatform) ShowPicker ¶
func (m *MockPlatform) ShowPicker(cfg *config.Instance, args widgetmodels.PickerArgs) error
ShowPicker displays a list picker on-screen of the platform device
func (*MockPlatform) StartPost ¶
func (m *MockPlatform) StartPost(cfg *config.Instance, getActiveMedia func() *models.ActiveMedia, setActiveMedia func(*models.ActiveMedia), ) error
StartPost runs any necessary platform setup AFTER the main service has started running
func (*MockPlatform) StartPre ¶
func (m *MockPlatform) StartPre(cfg *config.Instance) error
StartPre runs any necessary platform setup BEFORE the main service has started running
func (*MockPlatform) Stop ¶
func (m *MockPlatform) Stop() error
Stop runs any necessary cleanup tasks before the rest of the service starts shutting down
func (*MockPlatform) StopActiveLauncher ¶
func (m *MockPlatform) StopActiveLauncher() error
StopActiveLauncher kills/exits the currently running launcher process
func (*MockPlatform) SupportedReaders ¶
func (m *MockPlatform) SupportedReaders(cfg *config.Instance) []readers.Reader
SupportedReaders returns a list of supported reader modules for platform
type MockReader ¶
MockReader is a mock implementation of the Reader interface using testify/mock
func NewMockReader ¶
func NewMockReader() *MockReader
NewMockReader creates a new MockReader instance
func (*MockReader) CancelWrite ¶
func (m *MockReader) CancelWrite()
CancelWrite sends a request to cancel an active write request
func (*MockReader) Capabilities ¶
func (m *MockReader) Capabilities() []readers.Capability
Capabilities returns the list of capabilities supported by this reader
func (*MockReader) Close ¶
func (m *MockReader) Close() error
Close any open connections to the device and stop polling
func (*MockReader) Connected ¶
func (m *MockReader) Connected() bool
Connected returns true if the device is connected and active
func (*MockReader) Detect ¶
func (m *MockReader) Detect(devices []string) string
Detect attempts to search for a connected device and returns the device connection string
func (*MockReader) Device ¶
func (m *MockReader) Device() string
Device returns the device connection string
func (*MockReader) IDs ¶
func (m *MockReader) IDs() []string
IDs returns the device string prefixes supported by this reader
func (*MockReader) Info ¶
func (m *MockReader) Info() string
Info returns a string with information about the connected device
func (*MockReader) Metadata ¶
func (m *MockReader) Metadata() readers.DriverMetadata
Metadata returns static configuration for this driver
func (*MockReader) OnMediaChange ¶
func (m *MockReader) OnMediaChange(media *models.ActiveMedia) error
OnMediaChange is called when the active media changes
func (*MockReader) Open ¶
func (m *MockReader) Open(readerConfig config.ReadersConnect, scanChan chan<- readers.Scan) error
Open any necessary connections to the device and start polling
func (*MockReader) SetupBasicMock ¶
func (m *MockReader) SetupBasicMock()
SetupBasicMock configures the mock with typical default values for basic operations
func (*MockReader) SimulateError ¶
func (*MockReader) SimulateError(scanChan chan<- readers.Scan, err error, source string)
SimulateError sends an error scan to the provided channel (for testing Open method)
func (*MockReader) SimulateTokenScan ¶
func (*MockReader) SimulateTokenScan(scanChan chan<- readers.Scan, token *tokens.Token, source string)
SimulateTokenScan sends a token scan to the provided channel (for testing Open method)