testutil

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 10 Imported by: 0 modules, 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 AssertContains

func AssertContains[T comparable](t *testing.T, slice []T, elem T)

AssertContains calls t.Errorf if slice does not contain elem.

func AssertEqual

func AssertEqual[T comparable](t *testing.T, want, got T)

AssertEqual calls t.Errorf if got != want.

func AssertError

func AssertError(t *testing.T, err error)

AssertError calls t.Fatal if err is nil.

func AssertJSONEqual

func AssertJSONEqual(t *testing.T, want, got any)

AssertJSONEqual marshals both values to JSON and compares the results. Useful for comparing structs that contain unexported fields or time.Time values.

func AssertLen

func AssertLen[T any](t *testing.T, slice []T, want int)

AssertLen calls t.Errorf if len(slice) != want.

func AssertNoError

func AssertNoError(t *testing.T, err error)

AssertNoError calls t.Fatal if err is non-nil.

func AssertNotEqual

func AssertNotEqual[T comparable](t *testing.T, notWant, got T)

AssertNotEqual calls t.Errorf if got == notWant.

func NewTestDB

func NewTestDB(t *testing.T) *dbgen.Queries

NewTestDB creates a fresh SQLite database with all migrations applied. The database is registered with t.Cleanup to be closed after the test completes. Each call gets its own file under t.TempDir() so tests never share state.

func NewTestDBWithSQL

func NewTestDBWithSQL(t *testing.T) (*dbgen.Queries, *sql.DB)

NewTestDBWithSQL returns both the Queries and the underlying *sql.DB. Use this when you need to execute raw SQL in tests (e.g. for low-level assertions).

func SeedGrabHistory

func SeedGrabHistory(t *testing.T, q *dbgen.Queries, movieID, title string) dbgen.GrabHistory

SeedGrabHistory inserts one grab_history row for movieID and returns it.

func SeedLibrary

func SeedLibrary(t *testing.T, q *dbgen.Queries) dbgen.Library

SeedLibrary inserts a library backed by a freshly created quality profile.

func SeedLibraryWithProfile

func SeedLibraryWithProfile(t *testing.T, q *dbgen.Queries, profileID string) dbgen.Library

SeedLibraryWithProfile inserts a library using the given quality profile ID.

func SeedMovie

func SeedMovie(t *testing.T, q *dbgen.Queries, opts ...MovieOption) dbgen.Movie

SeedMovie inserts a movie into a freshly created library with sensible defaults.

func SeedMovieInLibrary

func SeedMovieInLibrary(t *testing.T, q *dbgen.Queries, libraryID, profileID string, opts ...MovieOption) dbgen.Movie

SeedMovieInLibrary inserts a movie into the specified library.

func SeedQualityProfile

func SeedQualityProfile(t *testing.T, q *dbgen.Queries) dbgen.QualityProfile

SeedQualityProfile inserts a quality profile with sensible defaults and returns it. The inserted profile accepts 1080p BluRay releases.

Types

type MovieOption

type MovieOption func(*dbgen.CreateMovieParams)

MovieOption is a functional option for SeedMovie.

func WithMonitored

func WithMonitored(monitored bool) MovieOption

WithMonitored sets the monitored flag on the seeded movie.

func WithMovieStatus

func WithMovieStatus(status string) MovieOption

WithMovieStatus sets the status field on the seeded movie.

func WithTMDBID

func WithTMDBID(id int) MovieOption

WithTMDBID sets the TMDB ID on the seeded movie.

Directories

Path Synopsis
Package mock provides hand-written mock implementations of Prism's plugin interfaces for use in unit and integration tests.
Package mock provides hand-written mock implementations of Prism's plugin interfaces for use in unit and integration tests.

Jump to

Keyboard shortcuts

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