testsupport

package
v0.4.37 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: AGPL-3.0 Imports: 3 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 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

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

func (*NopStore) BackoffByPrefix added in v0.4.0

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

func (*NopStore) BackoffItems added in v0.4.0

func (*NopStore) BackoffItems(context.Context) ([]subflux.BackoffEntry, error)

BackoffItems returns all items currently in adaptive search backoff.

func (*NopStore) BackupInto added in v0.4.0

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

BackupInto reports success without writing a snapshot.

func (*NopStore) CleanupDrift

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

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

func (*NopStore) ClearManualLock

func (*NopStore) ClearManualLock(context.Context, subflux.ManualLockKey) error

ClearManualLock removes the manual download lock on the key's quad.

func (*NopStore) ClearScanCycleStart added in v0.1.148

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

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

func (*NopStore) DeleteStateByPaths(context.Context, []string) (subflux.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) HistoryMediaIDs

func (*NopStore) HistoryMediaIDs(context.Context, subflux.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, subflux.ManualLockKey) (bool, error)

IsManuallyLocked reports whether the key's quad 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) ManualLocks added in v0.4.0

func (*NopStore) ManualLocks(context.Context) ([]subflux.ManualLockEntry, error)

ManualLocks returns all active manual download locks.

func (*NopStore) ManualSubtitlePaths

func (*NopStore) ManualSubtitlePaths(context.Context, subflux.ManualLockKey) ([]string, error)

ManualSubtitlePaths returns paths of manually downloaded subtitle files on the key's quad.

func (*NopStore) NextManualNumber

func (*NopStore) NextManualNumber(context.Context, subflux.ManualLockKey) int

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

func (*NopStore) PollTimestamp added in v0.4.0

func (*NopStore) PollTimestamp(context.Context, subflux.PollKey) (time.Time, error)

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

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) (subflux.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, *subflux.ScanRecord) error

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

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

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

func (*NopStore) ScanStates added in v0.4.0

ScanStates returns scan state records for a media item prefix.

func (*NopStore) SetPollTimestamp

func (*NopStore) SetPollTimestamp(context.Context, subflux.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) State added in v0.4.0

State returns download state entries matching the query.

func (*NopStore) Stats

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

Stats returns aggregate counts for downloads and active backoff entries.

func (*NopStore) StoreFileStats added in v0.4.0

func (*NopStore) StoreFileStats() (fileBytes, freelistBytes int64)

StoreFileStats reports an empty store.

func (*NopStore) SubtitleFiles added in v0.4.0

SubtitleFiles returns subtitle file records for a media item.

func (*NopStore) SyncOffset added in v0.4.0

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

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

func (*NopStore) TotalSubtitleFiles

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

TotalSubtitleFiles returns the total number of tracked subtitle file records.

func (*NopStore) UpsertSubtitleFile

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