Documentation
¶
Overview ¶
Package testsupport provides shared test helpers used across multiple packages. It avoids duplicating mock implementations in each test file.
Index ¶
- type NopStore
- func (*NopStore) BackedOffProviders(context.Context, subflux.MediaType, string, string, int) ([]subflux.ProviderID, error)
- func (*NopStore) BackoffByPrefix(context.Context, subflux.MediaType, string) ([]subflux.BackoffEntry, error)
- func (*NopStore) BackoffItems(context.Context) ([]subflux.BackoffEntry, error)
- func (*NopStore) BackupInto(context.Context, string) error
- func (*NopStore) CleanupDrift(context.Context, subflux.ConfigDrift) error
- func (*NopStore) ClearManualLock(context.Context, subflux.ManualLockKey) error
- func (*NopStore) ClearScanCycleStart(context.Context) error
- func (*NopStore) CurrentScore(context.Context, subflux.MediaType, string, string, subflux.Variant) (score int, at time.Time, found bool, _ error)
- func (*NopStore) DeleteStateByPaths(context.Context, []string) (subflux.CleanupResult, error)
- func (*NopStore) DeleteSubtitleFile(context.Context, subflux.MediaType, string, string, subflux.Variant, ...) error
- func (*NopStore) DownloadedRefs(context.Context, subflux.MediaType, string, string) ([]subflux.DownloadedRef, error)
- func (*NopStore) HistoryMediaIDs(context.Context, subflux.MediaType, string) ([]string, error)
- func (*NopStore) IsManuallyLocked(context.Context, subflux.ManualLockKey) (bool, error)
- func (*NopStore) LastScanTime(context.Context) (string, error)
- func (*NopStore) ManualLocks(context.Context) ([]subflux.ManualLockEntry, error)
- func (*NopStore) ManualSubtitlePaths(context.Context, subflux.ManualLockKey) ([]string, error)
- func (*NopStore) NextManualNumber(context.Context, subflux.ManualLockKey) int
- func (*NopStore) PollTimestamp(context.Context, subflux.PollKey) (time.Time, error)
- func (*NopStore) RecentlyScanned(context.Context, time.Time) (map[string]bool, error)
- func (*NopStore) ReconcileState(context.Context) (subflux.ReconcileResult, error)
- func (*NopStore) RecordNoResult(context.Context, subflux.MediaType, string, string, subflux.ProviderID, ...) error
- func (*NopStore) RecordScanState(context.Context, *subflux.ScanRecord) error
- func (*NopStore) RecordSubtitleFiles(context.Context, subflux.MediaType, string, []subflux.SubtitleFile) (bool, error)
- func (*NopStore) SaveDownload(context.Context, *subflux.DownloadRecord) error
- func (*NopStore) ScanCycleStart(context.Context) (time.Time, error)
- func (*NopStore) ScanStates(context.Context, subflux.MediaType, string) ([]subflux.ScanStateRow, error)
- func (*NopStore) SetPollTimestamp(context.Context, subflux.PollKey, time.Time) error
- func (*NopStore) SetScanCycleStart(context.Context, time.Time) error
- func (*NopStore) SetSyncOffset(context.Context, string, int64) error
- func (*NopStore) State(context.Context, *subflux.StateQuery) ([]subflux.StateEntry, error)
- func (*NopStore) Stats(context.Context) (downloads, backoffs int, _ error)
- func (*NopStore) StoreFileStats() (fileBytes, freelistBytes int64)
- func (*NopStore) SubtitleFiles(context.Context, subflux.MediaType, string) ([]subflux.SubtitleEntry, error)
- func (*NopStore) SyncOffset(context.Context, string) (int64, error)
- func (*NopStore) TotalSubtitleFiles(context.Context) (int, error)
- func (*NopStore) UpsertSubtitleFile(context.Context, subflux.MediaType, string, *subflux.SubtitleFile) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NopStore ¶
type NopStore struct{}
NopStore is the shared store fake: every method returns a zero value and nothing is persisted. Embed it in a test-specific mock and override only the methods that test exercises.
Its WIDTH is now derived, not declared. There is no store interface for it to be exhaustive against any more, so what it must implement is exactly the union of the narrow interfaces the eight packages that use it install it as (search.Store, scanning.ScanStore, scheduler.Store, queryhandlers.QueryStore, synchandlers.SyncStore, filehandlers.FileStore, coveragehandlers.CoverageStore, manualops.DownloadStore, polling.PollerStore, resolve.FileStore, coverage.FileReader, and server.Store, which is the union of most of those). nopstore_test.go states that union in one anonymous interface, so a consumer that adds a method fails there with a readable message rather than at a dozen install sites.
Two methods went with the composite because nothing reaches them through an interface: Close (main.go calls it on the concrete *boltstore.DB) and ManualDownloadCount (boltstore's own NextManualNumber fallback and its tests are the only callers). A sibling panicStore used to shadow all 36 methods so that a new one would announce itself; every one of them was overridden here, so it was 159 lines that changed no behaviour, and it is gone.
func (*NopStore) BackedOffProviders ¶
func (*NopStore) BackedOffProviders(context.Context, subflux.MediaType, string, string, int) ([]subflux.ProviderID, error)
BackedOffProviders returns providers currently in backoff for the given media item.
func (*NopStore) BackoffByPrefix ¶ added in v0.4.0
func (*NopStore) BackoffByPrefix(context.Context, subflux.MediaType, string) ([]subflux.BackoffEntry, error)
BackoffByPrefix returns backoff entries matching the given media type and ID prefix.
func (*NopStore) BackoffItems ¶ added in v0.4.0
BackoffItems returns all items currently in adaptive search backoff.
func (*NopStore) BackupInto ¶ added in v0.4.0
BackupInto reports success without writing a snapshot.
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 on the key's quad.
func (*NopStore) ClearScanCycleStart ¶ added in v0.1.148
ClearScanCycleStart is a no-op.
func (*NopStore) CurrentScore ¶
func (*NopStore) CurrentScore(context.Context, subflux.MediaType, string, string, subflux.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, subflux.MediaType, string, string, subflux.Variant, subflux.SubtitleSource, string) error
DeleteSubtitleFile removes a subtitle file record for a media item.
func (*NopStore) DownloadedRefs ¶
func (*NopStore) DownloadedRefs(context.Context, subflux.MediaType, string, string) ([]subflux.DownloadedRef, error)
DownloadedRefs returns the previously downloaded subtitle references for a media item.
func (*NopStore) HistoryMediaIDs ¶
HistoryMediaIDs returns distinct media IDs with download history for the given type and language.
func (*NopStore) IsManuallyLocked ¶
IsManuallyLocked reports whether the key's quad has a manual download lock.
func (*NopStore) LastScanTime ¶
LastScanTime returns the formatted timestamp of the most recent scan completion.
func (*NopStore) ManualLocks ¶ added in v0.4.0
ManualLocks returns all active manual download locks.
func (*NopStore) ManualSubtitlePaths ¶
ManualSubtitlePaths returns paths of manually downloaded subtitle files on the key's quad.
func (*NopStore) NextManualNumber ¶
NextManualNumber returns the next sequential number for a manual subtitle file.
func (*NopStore) PollTimestamp ¶ added in v0.4.0
PollTimestamp returns the last poll timestamp for the given poll key.
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, subflux.MediaType, string, string, subflux.ProviderID, subflux.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, subflux.MediaType, string, []subflux.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) ScanCycleStart ¶ added in v0.1.148
ScanCycleStart returns the zero time (no cycle mark stored).
func (*NopStore) ScanStates ¶ added in v0.4.0
func (*NopStore) ScanStates(context.Context, subflux.MediaType, string) ([]subflux.ScanStateRow, error)
ScanStates returns scan state records for a media item prefix.
func (*NopStore) SetPollTimestamp ¶
SetPollTimestamp stores the poll timestamp for the given poll key.
func (*NopStore) SetScanCycleStart ¶ added in v0.1.148
SetScanCycleStart is a no-op.
func (*NopStore) SetSyncOffset ¶
SetSyncOffset stores the subtitle timing offset in milliseconds for a video path.
func (*NopStore) State ¶ added in v0.4.0
func (*NopStore) State(context.Context, *subflux.StateQuery) ([]subflux.StateEntry, error)
State returns download state entries matching the query.
func (*NopStore) StoreFileStats ¶ added in v0.4.0
StoreFileStats reports an empty store.
func (*NopStore) SubtitleFiles ¶ added in v0.4.0
func (*NopStore) SubtitleFiles(context.Context, subflux.MediaType, string) ([]subflux.SubtitleEntry, error)
SubtitleFiles returns subtitle file records for a media item.
func (*NopStore) SyncOffset ¶ added in v0.4.0
SyncOffset returns the stored timing offset in milliseconds for a video path.
func (*NopStore) TotalSubtitleFiles ¶
TotalSubtitleFiles returns the total number of tracked subtitle file records.