mocks

package
v2.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: GPL-3.0 Imports: 19 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestJSONRPCError

func CreateTestJSONRPCError(id any, code int, message string) []byte

CreateTestJSONRPCError creates a test JSON-RPC error response

func CreateTestJSONRPCMessage

func CreateTestJSONRPCMessage(method string, params any) []byte

CreateTestJSONRPCMessage creates a test JSON-RPC message

func CreateTestJSONRPCResponse

func CreateTestJSONRPCResponse(id, result any) []byte

CreateTestJSONRPCResponse creates a test JSON-RPC response

Types

type MockAPIClient added in v2.9.0

type MockAPIClient struct {
	mock.Mock
}

MockAPIClient is a mock implementation of client.APIClient for testing.

func NewMockAPIClient added in v2.9.0

func NewMockAPIClient() *MockAPIClient

NewMockAPIClient creates a new mock API client.

func (*MockAPIClient) Call added in v2.9.0

func (m *MockAPIClient) Call(ctx context.Context, method, params string) (string, error)

Call mocks the API call method.

func (*MockAPIClient) SetupCancelWriteTagError added in v2.9.0

func (m *MockAPIClient) SetupCancelWriteTagError(err error)

SetupCancelWriteTagError configures the mock to return an error for cancel write.

func (*MockAPIClient) SetupCancelWriteTagSuccess added in v2.9.0

func (m *MockAPIClient) SetupCancelWriteTagSuccess()

SetupCancelWriteTagSuccess configures the mock to accept cancel write operations.

func (*MockAPIClient) SetupReadersError added in v2.9.0

func (m *MockAPIClient) SetupReadersError(err error)

SetupReadersError configures the mock to return an error for readers.

func (*MockAPIClient) SetupReadersResponse added in v2.9.0

func (m *MockAPIClient) SetupReadersResponse(readers *models.ReadersResponse)

SetupReadersResponse configures the mock to return a readers response.

func (*MockAPIClient) SetupRemoteActivityError added in v2.17.0

func (m *MockAPIClient) SetupRemoteActivityError(err error)

SetupRemoteActivityError configures the mock to return an error for remote activity.

func (*MockAPIClient) SetupRemoteActivityResponse added in v2.17.0

func (m *MockAPIClient) SetupRemoteActivityResponse(activity *models.RemoteActivityResponse)

SetupRemoteActivityResponse configures the mock to return a remote activity response.

func (*MockAPIClient) SetupSearchMediaError added in v2.9.0

func (m *MockAPIClient) SetupSearchMediaError(err error)

SetupSearchMediaError configures the mock to return an error for media search.

func (*MockAPIClient) SetupSearchMediaResponse added in v2.9.0

func (m *MockAPIClient) SetupSearchMediaResponse(results *models.SearchResults)

SetupSearchMediaResponse configures the mock to return search results.

func (*MockAPIClient) SetupSettingsError added in v2.9.0

func (m *MockAPIClient) SetupSettingsError(err error)

SetupSettingsError configures the mock to return an error for settings.

func (*MockAPIClient) SetupSettingsResponse added in v2.9.0

func (m *MockAPIClient) SetupSettingsResponse(settings *models.SettingsResponse)

SetupSettingsResponse configures the mock to return a settings response.

func (*MockAPIClient) SetupSystemsError added in v2.9.0

func (m *MockAPIClient) SetupSystemsError(err error)

SetupSystemsError configures the mock to return an error for systems.

func (*MockAPIClient) SetupSystemsResponse added in v2.9.0

func (m *MockAPIClient) SetupSystemsResponse(systems []models.System)

SetupSystemsResponse configures the mock to return a systems response.

func (*MockAPIClient) SetupTokenNotification added in v2.9.0

func (m *MockAPIClient) SetupTokenNotification(token *models.TokenResponse)

SetupTokenNotification configures the mock to return a token notification.

func (*MockAPIClient) SetupTokensError added in v2.9.0

func (m *MockAPIClient) SetupTokensError(err error)

SetupTokensError configures the mock to return an error for tokens.

func (*MockAPIClient) SetupTokensResponse added in v2.9.0

func (m *MockAPIClient) SetupTokensResponse(tokens *models.TokensResponse)

SetupTokensResponse configures the mock to return a tokens response.

func (*MockAPIClient) SetupUpdateSettingsError added in v2.9.0

func (m *MockAPIClient) SetupUpdateSettingsError(err error)

SetupUpdateSettingsError configures the mock to return an error on update.

func (*MockAPIClient) SetupUpdateSettingsSuccess added in v2.9.0

func (m *MockAPIClient) SetupUpdateSettingsSuccess()

SetupUpdateSettingsSuccess configures the mock to accept settings updates.

func (*MockAPIClient) SetupWriteTagError added in v2.9.0

func (m *MockAPIClient) SetupWriteTagError(err error)

SetupWriteTagError configures the mock to return an error for write tag.

func (*MockAPIClient) SetupWriteTagSuccess added in v2.9.0

func (m *MockAPIClient) SetupWriteTagSuccess()

SetupWriteTagSuccess configures the mock to accept write tag operations.

func (*MockAPIClient) WaitNotification added in v2.9.0

func (m *MockAPIClient) WaitNotification(
	ctx context.Context,
	timeout time.Duration,
	notificationType string,
) (string, error)

WaitNotification mocks waiting for a notification.

type MockCommandExecutor added in v2.7.0

type MockCommandExecutor struct {
	mock.Mock
}

MockCommandExecutor is a testify mock for command.Executor. It allows testing code that executes system commands without actually running them.

func (*MockCommandExecutor) Output added in v2.8.0

func (m *MockCommandExecutor) Output(ctx context.Context, name string, args ...string) ([]byte, error)

Output mocks command execution that returns output. Use On() to set expectations and Return() to control the mock behavior.

Example:

mockCmd := &MockCommandExecutor{}
mockCmd.On("Output", mock.Anything, "xprop", mock.Anything).Return([]byte("output"), nil)

func (*MockCommandExecutor) Run added in v2.7.0

func (m *MockCommandExecutor) Run(ctx context.Context, name string, args ...string) error

Run mocks the execution of a system command. Use On() to set expectations and Return() to control the mock behavior.

Example:

mockCmd := &MockCommandExecutor{}
mockCmd.On("Run", mock.Anything, "systemctl", mock.Anything).Return(nil)

func (*MockCommandExecutor) Start added in v2.8.0

func (m *MockCommandExecutor) Start(ctx context.Context, name string, args ...string) error

Start mocks starting a command without waiting for completion. Use On() to set expectations and Return() to control the mock behavior.

Example:

mockCmd := &MockCommandExecutor{}
mockCmd.On("Start", mock.Anything, "steam", mock.Anything).Return(nil)

func (*MockCommandExecutor) StartWithOptions added in v2.8.0

func (m *MockCommandExecutor) StartWithOptions(
	ctx context.Context,
	opts command.StartOptions,
	name string,
	args ...string,
) error

StartWithOptions mocks starting a command with platform-specific options. Use On() to set expectations and Return() to control the mock behavior.

Example:

mockCmd := &MockCommandExecutor{}
opts := command.StartOptions{HideWindow: true}
mockCmd.On("StartWithOptions", mock.Anything, opts, "cmd", mock.Anything).Return(nil)

type MockKodiClient

type MockKodiClient struct {
	mock.Mock
}

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(ctx context.Context, method kodi.APIMethod, params any) (json.RawMessage, error)

APIRequest mocks making a raw JSON-RPC request to Kodi API

func (*MockKodiClient) FastForward added in v2.10.0

func (m *MockKodiClient) FastForward(ctx context.Context) error

FastForward mocks increasing playback speed of the first active player

func (*MockKodiClient) GetActivePlayers

func (m *MockKodiClient) GetActivePlayers(ctx context.Context) ([]kodi.Player, error)

GetActivePlayers mocks retrieving all active players in Kodi

func (*MockKodiClient) GetAlbums

func (m *MockKodiClient) GetAlbums(ctx context.Context) ([]kodi.Album, error)

GetAlbums mocks retrieving all albums from Kodi's library

func (*MockKodiClient) GetArtists

func (m *MockKodiClient) GetArtists(ctx context.Context) ([]kodi.Artist, error)

GetArtists mocks retrieving all artists from Kodi's library

func (*MockKodiClient) GetEpisodes

func (m *MockKodiClient) GetEpisodes(ctx context.Context, 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(ctx context.Context) ([]kodi.Movie, error)

GetMovies mocks retrieving all movies from Kodi's library

func (*MockKodiClient) GetPlayerItem added in v2.7.0

func (m *MockKodiClient) GetPlayerItem(ctx context.Context, playerID int) (*kodi.PlayerItem, error)

GetPlayerItem mocks retrieving the currently playing item for a specific player

func (*MockKodiClient) GetSongs

func (m *MockKodiClient) GetSongs(ctx context.Context) ([]kodi.Song, error)

GetSongs mocks retrieving all songs from Kodi's library

func (*MockKodiClient) GetTVShows

func (m *MockKodiClient) GetTVShows(ctx context.Context) ([]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) GoTo added in v2.10.0

func (m *MockKodiClient) GoTo(ctx context.Context, direction string) error

GoTo mocks navigating to next or previous item in playlist

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) PlayPause added in v2.10.0

func (m *MockKodiClient) PlayPause(ctx context.Context) error

PlayPause mocks toggling play/pause on the first active player

func (*MockKodiClient) Quit added in v2.7.0

func (m *MockKodiClient) Quit(ctx context.Context) error

Quit mocks gracefully exiting Kodi application

func (*MockKodiClient) Rewind added in v2.10.0

func (m *MockKodiClient) Rewind(ctx context.Context) error

Rewind mocks decreasing playback speed of the first active player

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(ctx context.Context) 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

func (m *MockMelody) BroadcastFilter(msg []byte, filter func(*melody.Session) bool) error

BroadcastFilter mocks broadcasting with a filter function

func (*MockMelody) ClearSessions

func (m *MockMelody) ClearSessions()

ClearSessions removes all sessions

func (*MockMelody) Close

func (m *MockMelody) Close() error

Close mocks closing 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

type MockPlatform struct {
	mock.Mock
	// contains filtered or unexported fields
}

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) ConsoleManager added in v2.7.0

func (m *MockPlatform) ConsoleManager() platforms.ConsoleManager

func (*MockPlatform) ForwardCmd

func (m *MockPlatform) ForwardCmd(env *platforms.CmdEnv) (platforms.CmdResult, error)

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. Unstubbed it returns "" rather than panicking: it is read by diagnostics that run on paths a test may not be exercising deliberately, and an incomplete mock should not fail those.

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, launcher *platforms.Launcher, db *database.Database,
	opts *platforms.LaunchOptions,
) 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) ManagedByPackageManager added in v2.10.0

func (m *MockPlatform) ManagedByPackageManager() bool

ManagedByPackageManager returns whether this install is managed by a package manager

func (*MockPlatform) PowerStatus added in v2.17.0

func (m *MockPlatform) PowerStatus() (power.Status, error)

PowerStatus reports the device's power state. It is deliberately not a testify expectation: every test that reaches the updater would otherwise have to declare one, and the answer a test does not care about should not depend on whether the machine running it has a wireless mouse.

func (*MockPlatform) ReturnToMenu added in v2.7.0

func (m *MockPlatform) ReturnToMenu() error

ReturnToMenu returns the platform to its main UI/launcher/frontend

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) Scrapers added in v2.12.0

func (m *MockPlatform) Scrapers(cfg *config.Instance) map[string]platforms.Scraper

Scrapers defaults to no registered scrapers. Index fixtures opt in explicitly; existing platform fixtures do not implicitly request post-index work.

func (*MockPlatform) Screenshot added in v2.10.0

func (m *MockPlatform) Screenshot() (*platforms.ScreenshotResult, error)

Screenshot captures a screenshot of the current platform display

func (*MockPlatform) SetPowerStatus added in v2.17.0

func (m *MockPlatform) SetPowerStatus(status power.Status)

SetPowerStatus fixes what PowerStatus reports.

func (*MockPlatform) SetTrackedProcess added in v2.6.1

func (m *MockPlatform) SetTrackedProcess(proc *os.Process)

SetTrackedProcess stores a process handle for lifecycle management

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) StartPost

func (m *MockPlatform) StartPost(_ context.Context, _ *config.Instance,
	launcherManager platforms.LauncherContextManager,
	getActiveMedia func() *models.ActiveMedia, setActiveMedia func(*models.ActiveMedia),
	db *database.Database, scheduler *idle.Scheduler,
) 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(intent platforms.StopIntent) 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 MockPlayer added in v2.9.1

type MockPlayer struct {
	mock.Mock
}

MockPlayer is a testify mock for audio.Player.

func NewMockPlayer added in v2.9.1

func NewMockPlayer() *MockPlayer

NewMockPlayer creates a new MockPlayer instance.

func (*MockPlayer) ClearFileCache added in v2.9.1

func (m *MockPlayer) ClearFileCache()

func (*MockPlayer) PlayBytes added in v2.11.0

func (m *MockPlayer) PlayBytes(data []byte) error

func (*MockPlayer) PlayFile added in v2.9.1

func (m *MockPlayer) PlayFile(path string) error

func (*MockPlayer) SetVolume added in v2.11.0

func (m *MockPlayer) SetVolume(volume float64)

func (*MockPlayer) SetupNoOpMock added in v2.9.1

func (m *MockPlayer) SetupNoOpMock()

SetupNoOpMock configures all methods to succeed silently.

type MockReader

type MockReader struct {
	mock.Mock
}

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) 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,
	opts readers.OpenOpts,
) error

Open any necessary connections to the device and start polling

func (*MockReader) Path added in v2.9.0

func (m *MockReader) Path() string

Path returns the connection path used to open this reader

func (*MockReader) ReaderID added in v2.9.0

func (m *MockReader) ReaderID() string

ReaderID returns a deterministic identifier for this reader instance

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)

func (*MockReader) Write

func (m *MockReader) Write(data string) (*tokens.Token, error)

Write sends a string to the device to be written to a token

func (*MockReader) WriteTarget added in v2.13.0

func (m *MockReader) WriteTarget(ctx context.Context, data string, opts readers.WriteOptions) (*tokens.Token, error)

WriteTarget sends a string to a specific target token.

type WebSocketTestMessage

type WebSocketTestMessage struct {
	Timestamp time.Time `json:"timestamp"`
	Data      any       `json:"data"`
	Type      string    `json:"type"`
}

WebSocketTestMessage represents a test message structure

Jump to

Keyboard shortcuts

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