testsupport

package
v0.1.151 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: GPL-2.0, GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testsupport provides shared test helpers used across multiple packages. It avoids duplicating mock implementations in each test file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NopConfig

type NopConfig struct {
	PathErr      error
	ProviderCfgs map[api.ProviderID]api.ProviderCfg
	RadarrCfg    api.ArrConfig
	SonarrCfg    api.ArrConfig
	LangRules    api.LanguageRulesJSON
	Languages    []string
	Targets      []api.SubtitleTarget
	SearchConfig api.SearchConfig
	AdaptiveCfg  api.AdaptiveConfig
	Sync         api.SyncConfig
	MinScore     int
	ProviderPrio int
	PostProcess  api.PostProcessConfig
	Embedded     api.EmbeddedPolicy
}

NopConfig is a zero-value implementation of api.ConfigProvider (a superset of search.SearchCfg) for tests. Embed it in test-specific mocks and override only the methods you need, or set the exported fields for the common knobs. Note: the compile-time assertion against search.SearchCfg lives in search test code to avoid testsupport→search→testsupport import cycles (search test code imports testsupport).

func (*NopConfig) Adaptive

func (n *NopConfig) Adaptive() api.AdaptiveConfig

Adaptive returns the configured adaptive backoff settings.

func (*NopConfig) AuthEnabled added in v0.1.148

func (n *NopConfig) AuthEnabled() bool

AuthEnabled reports auth as disabled.

func (*NopConfig) BasicAuthEnabled added in v0.1.148

func (n *NopConfig) BasicAuthEnabled() bool

BasicAuthEnabled reports basic auth as enabled.

func (*NopConfig) CheckBreachedPasswords added in v0.1.148

func (n *NopConfig) CheckBreachedPasswords() bool

CheckBreachedPasswords reports breach checking as disabled.

func (*NopConfig) EmbeddedPolicy added in v0.1.148

func (n *NopConfig) EmbeddedPolicy() api.EmbeddedPolicy

EmbeddedPolicy returns the configured embedded subtitle codec policy.

func (*NopConfig) LanguageCodes added in v0.1.148

func (n *NopConfig) LanguageCodes() []string

LanguageCodes returns the configured language codes.

func (*NopConfig) LanguageRulesForUI added in v0.1.148

func (n *NopConfig) LanguageRulesForUI() api.LanguageRulesJSON

LanguageRulesForUI returns the configured language rules.

func (*NopConfig) LoggingFormat added in v0.1.148

func (n *NopConfig) LoggingFormat() api.LogFormat

LoggingFormat returns the json log format.

func (*NopConfig) LoggingLevel added in v0.1.148

func (n *NopConfig) LoggingLevel() api.LogLevel

LoggingLevel returns the info log level.

func (*NopConfig) MediaRoots added in v0.1.148

func (n *NopConfig) MediaRoots() []string

MediaRoots returns no media roots.

func (*NopConfig) MinScoreForTarget

func (n *NopConfig) MinScoreForTarget(_ *api.SubtitleTarget, _ api.MediaType) int

MinScoreForTarget returns the configured minimum score.

func (*NopConfig) OIDCConfig added in v0.1.148

func (n *NopConfig) OIDCConfig() auth.OIDCConfig

OIDCConfig returns an empty OIDC configuration.

func (*NopConfig) OIDCEnabled added in v0.1.148

func (n *NopConfig) OIDCEnabled() bool

OIDCEnabled reports OIDC as disabled.

func (*NopConfig) PollInterval added in v0.1.148

func (n *NopConfig) PollInterval() time.Duration

PollInterval returns a fixed 30s poll interval.

func (*NopConfig) PostProcessConfig

func (n *NopConfig) PostProcessConfig() api.PostProcessConfig

PostProcessConfig returns the configured post-processing settings.

func (*NopConfig) ProviderConfigs

func (n *NopConfig) ProviderConfigs() map[api.ProviderID]api.ProviderCfg

ProviderConfigs returns the configured provider configuration map.

func (*NopConfig) ProviderPriority

func (n *NopConfig) ProviderPriority(_ api.ProviderID) int

ProviderPriority returns the configured provider priority value.

func (*NopConfig) ProvidersForTarget

func (n *NopConfig) ProvidersForTarget(_ *api.SubtitleTarget, all []api.ProviderID) []api.ProviderID

ProvidersForTarget returns all providers unchanged (no include/exclude filtering).

func (*NopConfig) RadarrConfig added in v0.1.148

func (n *NopConfig) RadarrConfig() api.ArrConfig

RadarrConfig returns the configured Radarr connection settings.

func (*NopConfig) RemoveUnderRoot added in v0.1.148

func (n *NopConfig) RemoveUnderRoot(_ context.Context, path string) error

RemoveUnderRoot returns PathErr when set; otherwise it removes the file, tolerating already-missing paths (mirrors the production loose semantics tests rely on for nonexistent-path delete flows).

func (*NopConfig) ResolveTargetsWithFallback added in v0.1.148

func (n *NopConfig) ResolveTargetsWithFallback(_ string, _ []string) []api.SubtitleTarget

ResolveTargetsWithFallback returns the configured subtitle targets.

func (*NopConfig) Scores

func (n *NopConfig) Scores() api.Scores

Scores returns the default scoring weights.

func (*NopConfig) Search

func (n *NopConfig) Search() api.SearchConfig

Search returns the configured search settings.

func (*NopConfig) ServerPort added in v0.1.148

func (n *NopConfig) ServerPort() int

ServerPort returns the default subflux port.

func (*NopConfig) SessionAbsoluteTimeout added in v0.1.148

func (n *NopConfig) SessionAbsoluteTimeout() time.Duration

SessionAbsoluteTimeout returns a 7-day absolute timeout.

func (*NopConfig) SessionIdleTimeout added in v0.1.148

func (n *NopConfig) SessionIdleTimeout() time.Duration

SessionIdleTimeout returns a 24h idle timeout.

func (*NopConfig) SonarrConfig added in v0.1.148

func (n *NopConfig) SonarrConfig() api.ArrConfig

SonarrConfig returns the configured Sonarr connection settings.

func (*NopConfig) SyncConfig

func (n *NopConfig) SyncConfig() api.SyncConfig

SyncConfig returns the configured subtitle sync settings.

func (*NopConfig) ValidatePath added in v0.1.148

func (n *NopConfig) ValidatePath(_ context.Context, _ string) error

ValidatePath returns PathErr (nil by default, accepting every path).

func (*NopConfig) WebAuthnRPID added in v0.1.148

func (n *NopConfig) WebAuthnRPID() string

WebAuthnRPID returns an empty relying-party ID.

type NopStore

type NopStore struct {
	// contains filtered or unexported fields

} //nolint:unused // embedded for compile-time interface safety

NopStore implements api.Store with all methods returning zero/nil values. Embed it in test-specific mock structs and override only the methods relevant to each test case.

NopStore embeds panicStore (which panics on every method) and overrides all methods with no-op returns. When a new method is added to api.Store, only panicStore needs updating (the compiler tells you); NopStore then inherits the panic until the no-op override is added here.

func (*NopStore) BackedOffProviders

func (*NopStore) BackedOffProviders(context.Context, api.MediaType, string, string, int) ([]api.ProviderID, error)

BackedOffProviders returns providers currently in backoff for the given media item.

func (*NopStore) CleanupDrift

func (*NopStore) CleanupDrift(context.Context, api.ConfigDrift) error

CleanupDrift removes search_attempts entries for providers/languages that are no longer in the active configuration.

func (*NopStore) ClearManualLock

ClearManualLock removes the manual download lock for the given item and language.

func (*NopStore) ClearScanCycleStart added in v0.1.148

func (*NopStore) ClearScanCycleStart(context.Context) error

ClearScanCycleStart is a no-op.

func (*NopStore) Close

func (*NopStore) Close(context.Context) error

Close releases any resources held by the store.

func (*NopStore) CurrentScore

func (*NopStore) CurrentScore(context.Context, api.MediaType, string, string, api.Variant) (score int, at time.Time, found bool, _ error)

CurrentScore returns the current subtitle score for a media item and language.

func (*NopStore) DeleteStateByPaths

func (*NopStore) DeleteStateByPaths(context.Context, []string) (api.CleanupResult, error)

DeleteStateByPaths removes all state records associated with the given video paths.

func (*NopStore) DeleteSubtitleFile

DeleteSubtitleFile removes a subtitle file record for a media item.

func (*NopStore) DownloadedRefs

DownloadedRefs returns the previously downloaded subtitle references for a media item.

func (*NopStore) GetBackoffByPrefix

func (*NopStore) GetBackoffByPrefix(context.Context, api.MediaType, string) ([]api.BackoffEntry, error)

GetBackoffByPrefix returns backoff entries matching the given media type and ID prefix.

func (*NopStore) GetBackoffItems

func (*NopStore) GetBackoffItems(context.Context) ([]api.BackoffEntry, error)

GetBackoffItems returns all items currently in adaptive search backoff.

func (*NopStore) GetManualLocks

func (*NopStore) GetManualLocks(context.Context) ([]api.ManualLockEntry, error)

GetManualLocks returns all active manual download locks.

func (*NopStore) GetPollTimestamp

func (*NopStore) GetPollTimestamp(context.Context, api.PollKey) (time.Time, error)

GetPollTimestamp returns the last poll timestamp for the given poll key.

func (*NopStore) GetScanStates

func (*NopStore) GetScanStates(context.Context, api.MediaType, string) ([]api.ScanStateRow, error)

GetScanStates returns scan state records for a media item prefix.

func (*NopStore) GetState

GetState returns download state entries matching the query.

func (*NopStore) GetSubtitleFiles

func (*NopStore) GetSubtitleFiles(context.Context, api.MediaType, string) ([]api.SubtitleEntry, error)

GetSubtitleFiles returns subtitle file records for a media item.

func (*NopStore) GetSyncOffset

func (*NopStore) GetSyncOffset(context.Context, string) (int64, error)

GetSyncOffset returns the stored timing offset in milliseconds for a video path.

func (*NopStore) HistoryMediaIDs

func (*NopStore) HistoryMediaIDs(context.Context, api.MediaType, string) ([]string, error)

HistoryMediaIDs returns distinct media IDs with download history for the given type and language.

func (*NopStore) IsManuallyLocked

func (*NopStore) IsManuallyLocked(context.Context, api.MediaType, string, string, api.Variant) (bool, error)

IsManuallyLocked reports whether the item+language has a manual download lock.

func (*NopStore) LastScanTime

func (*NopStore) LastScanTime(context.Context) (string, error)

LastScanTime returns the formatted timestamp of the most recent scan completion.

func (*NopStore) ManualDownloadCount

func (*NopStore) ManualDownloadCount(context.Context, api.MediaType, string, string, api.Variant) (int, error)

ManualDownloadCount returns the number of manual subtitle downloads for the item+language.

func (*NopStore) ManualSubtitlePaths

func (*NopStore) ManualSubtitlePaths(context.Context, api.MediaType, string, string, api.Variant) ([]string, error)

ManualSubtitlePaths returns paths of manually downloaded subtitle files for the item+language.

func (*NopStore) NextManualNumber

func (*NopStore) NextManualNumber(context.Context, api.MediaType, string, string, api.Variant) int

NextManualNumber returns the next sequential number for a manual subtitle file.

func (*NopStore) RecentlyScanned

func (*NopStore) RecentlyScanned(context.Context, time.Time) (map[string]bool, error)

RecentlyScanned returns the set of media IDs scanned after the given cutoff time.

func (*NopStore) ReconcileState

func (*NopStore) ReconcileState(context.Context) (api.ReconcileResult, error)

ReconcileState performs the three-way filesystem reconciliation pass.

func (*NopStore) RecordNoResult

RecordNoResult records a provider returning no result for a media item, updating backoff state.

func (*NopStore) RecordScanState

func (*NopStore) RecordScanState(context.Context, *api.ScanRecord) error

RecordScanState records the scan timestamp and metadata for a media item.

func (*NopStore) RecordSubtitleFiles

func (*NopStore) RecordSubtitleFiles(context.Context, api.MediaType, string, []api.SubtitleFile) (bool, error)

RecordSubtitleFiles records the full set of subtitle files for a media item.

func (*NopStore) SaveDownload

func (*NopStore) SaveDownload(context.Context, *api.DownloadRecord) error

SaveDownload records or updates a subtitle download record.

func (*NopStore) ScanCycleStart added in v0.1.148

func (*NopStore) ScanCycleStart(context.Context) (time.Time, error)

ScanCycleStart returns the zero time (no cycle mark stored).

func (*NopStore) SetPollTimestamp

func (*NopStore) SetPollTimestamp(context.Context, api.PollKey, time.Time) error

SetPollTimestamp stores the poll timestamp for the given poll key.

func (*NopStore) SetScanCycleStart added in v0.1.148

func (*NopStore) SetScanCycleStart(context.Context, time.Time) error

SetScanCycleStart is a no-op.

func (*NopStore) SetSyncOffset

func (*NopStore) SetSyncOffset(context.Context, string, int64) error

SetSyncOffset stores the subtitle timing offset in milliseconds for a video path.

func (*NopStore) Stats

func (*NopStore) Stats(context.Context) (downloads, backoffs int, _ error)

Stats returns aggregate counts for downloads and active backoff entries.

func (*NopStore) TotalSubtitleFiles

func (*NopStore) TotalSubtitleFiles(context.Context) (int, error)

TotalSubtitleFiles returns the total number of tracked subtitle file records.

func (*NopStore) UpsertSubtitleFile

func (*NopStore) UpsertSubtitleFile(context.Context, api.MediaType, string, *api.SubtitleFile) error

UpsertSubtitleFile inserts or updates a single subtitle file record.

Jump to

Keyboard shortcuts

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