Documentation
¶
Overview ¶
Package testsupport provides shared test helpers used across multiple packages. It avoids duplicating mock implementations in each test file.
Index ¶
- type NopConfig
- func (n *NopConfig) Adaptive() api.AdaptiveConfig
- func (n *NopConfig) MinScoreForTarget(_ *api.SubtitleTarget, _ api.MediaType) int
- func (n *NopConfig) PostProcessConfig() api.PostProcessConfig
- func (n *NopConfig) ProviderConfigs() map[api.ProviderID]api.ProviderCfg
- func (n *NopConfig) ProviderPriority(_ api.ProviderID) int
- func (n *NopConfig) ProvidersForTarget(_ *api.SubtitleTarget, all []api.ProviderID) []api.ProviderID
- func (n *NopConfig) Scores() api.Scores
- func (n *NopConfig) Search() api.SearchConfig
- func (n *NopConfig) SyncConfig() api.SyncConfig
- type NopStore
- func (*NopStore) BackedOffProviders(context.Context, api.MediaType, string, string, int) ([]api.ProviderID, error)
- func (*NopStore) CleanupDrift(context.Context, api.ConfigDrift) error
- func (*NopStore) ClearManualLock(context.Context, api.MediaType, string, string, api.Variant) error
- func (*NopStore) Close(context.Context) error
- func (*NopStore) CurrentScore(context.Context, api.MediaType, string, string, api.Variant) (score int, at time.Time, found bool, _ error)
- func (*NopStore) DeleteStateByPaths(context.Context, []string) (api.CleanupResult, error)
- func (*NopStore) DeleteSubtitleFile(context.Context, api.MediaType, string, string, api.Variant, ...) error
- func (*NopStore) DownloadedRefs(context.Context, api.MediaType, string, string) ([]api.DownloadedRef, error)
- func (*NopStore) GetBackoffByPrefix(context.Context, api.MediaType, string) ([]api.BackoffEntry, error)
- func (*NopStore) GetBackoffItems(context.Context) ([]api.BackoffEntry, error)
- func (*NopStore) GetManualLocks(context.Context) ([]api.ManualLockEntry, error)
- func (*NopStore) GetPollTimestamp(context.Context, api.PollKey) (time.Time, error)
- func (*NopStore) GetScanStates(context.Context, api.MediaType, string) ([]api.ScanStateRow, error)
- func (*NopStore) GetState(context.Context, *api.StateQuery) ([]api.StateEntry, error)
- func (*NopStore) GetSubtitleFiles(context.Context, api.MediaType, string) ([]api.SubtitleEntry, error)
- func (*NopStore) GetSyncOffset(context.Context, string) (int64, error)
- func (*NopStore) HistoryMediaIDs(context.Context, api.MediaType, string) ([]string, error)
- func (*NopStore) IsManuallyLocked(context.Context, api.MediaType, string, string, api.Variant) (bool, error)
- func (*NopStore) LastScanTime(context.Context) (string, error)
- func (*NopStore) ManualDownloadCount(context.Context, api.MediaType, string, string, api.Variant) (int, error)
- func (*NopStore) ManualSubtitlePaths(context.Context, api.MediaType, string, string, api.Variant) ([]string, error)
- func (*NopStore) NextManualNumber(context.Context, api.MediaType, string, string, api.Variant) int
- func (*NopStore) RecentlyScanned(context.Context, time.Time) (map[string]bool, error)
- func (*NopStore) ReconcileState(context.Context) (api.ReconcileResult, error)
- func (*NopStore) RecordNoResult(context.Context, api.MediaType, string, string, api.ProviderID, ...) error
- func (*NopStore) RecordScanState(context.Context, *api.ScanRecord) error
- func (*NopStore) RecordSubtitleFiles(context.Context, api.MediaType, string, []api.SubtitleFile) (bool, error)
- func (*NopStore) SaveDownload(context.Context, *api.DownloadRecord) error
- func (*NopStore) SetPollTimestamp(context.Context, api.PollKey, time.Time) error
- func (*NopStore) SetSyncOffset(context.Context, string, int64) error
- func (*NopStore) Stats(context.Context) (downloads, backoffs int, _ error)
- func (*NopStore) TotalSubtitleFiles(context.Context) (int, error)
- func (*NopStore) UpsertSubtitleFile(context.Context, api.MediaType, string, *api.SubtitleFile) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NopConfig ¶
type NopConfig struct {
ProviderCfgs map[api.ProviderID]api.ProviderCfg
SearchConfig api.SearchConfig
AdaptiveCfg api.AdaptiveConfig
Sync api.SyncConfig
PostProcess api.PostProcessConfig
MinScore int
ProviderPrio int
}
NopConfig is a zero-value implementation of search.SearchCfg for tests. Embed it in test-specific mocks and override only the methods you need. Note: the compile-time assertion against search.SearchCfg lives in search/nopconfig_assert_test.go 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) MinScoreForTarget ¶
MinScoreForTarget returns the configured minimum score.
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) Search ¶
func (n *NopConfig) Search() api.SearchConfig
Search returns the configured search settings.
func (*NopConfig) SyncConfig ¶
func (n *NopConfig) SyncConfig() api.SyncConfig
SyncConfig returns the configured subtitle sync settings.
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 ¶
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) 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 ¶
DeleteStateByPaths removes all state records associated with the given video paths.
func (*NopStore) DeleteSubtitleFile ¶
func (*NopStore) DeleteSubtitleFile(context.Context, api.MediaType, string, string, api.Variant, api.SubtitleSource, string) error
DeleteSubtitleFile removes a subtitle file record for a media item.
func (*NopStore) DownloadedRefs ¶
func (*NopStore) DownloadedRefs(context.Context, api.MediaType, string, string) ([]api.DownloadedRef, error)
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 ¶
GetBackoffItems returns all items currently in adaptive search backoff.
func (*NopStore) GetManualLocks ¶
GetManualLocks returns all active manual download locks.
func (*NopStore) GetPollTimestamp ¶
GetPollTimestamp returns the last poll timestamp for the given poll key.
func (*NopStore) GetScanStates ¶
GetScanStates returns scan state records for a media item prefix.
func (*NopStore) GetState ¶
func (*NopStore) GetState(context.Context, *api.StateQuery) ([]api.StateEntry, error)
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 ¶
GetSyncOffset returns the stored timing offset in milliseconds for a video path.
func (*NopStore) HistoryMediaIDs ¶
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 ¶
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 ¶
NextManualNumber returns the next sequential number for a manual subtitle file.
func (*NopStore) RecentlyScanned ¶
RecentlyScanned returns the set of media IDs scanned after the given cutoff time.
func (*NopStore) ReconcileState ¶
ReconcileState performs the three-way filesystem reconciliation pass.
func (*NopStore) RecordNoResult ¶
func (*NopStore) RecordNoResult(context.Context, api.MediaType, string, string, api.ProviderID, api.BackoffParams) error
RecordNoResult records a provider returning no result for a media item, updating backoff state.
func (*NopStore) RecordScanState ¶
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 ¶
SaveDownload records or updates a subtitle download record.
func (*NopStore) SetPollTimestamp ¶
SetPollTimestamp stores the poll timestamp for the given poll key.
func (*NopStore) SetSyncOffset ¶
SetSyncOffset stores the subtitle timing offset in milliseconds for a video path.
func (*NopStore) TotalSubtitleFiles ¶
TotalSubtitleFiles returns the total number of tracked subtitle file records.