testutil

package
v0.0.0-...-694a361 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package testutil provides testing utilities for creating test metadata entries and filesystem structures.

Test Entry Builders

The package provides builder functions for creating pre-populated metadata.Entry instances:

Files:        CreateTestSubFile, CreateTestBonusFile, CreateTestEpFile, CreateTestMovieFile
Directories:  CreateTestSubDir, CreateTestBonusDir, CreateTestSeasonDir, CreateTestSeriesDir, CreateTestMovieDir

Each builder creates an entry with realistic metadata that matches expected patterns for its role, suitable for testing classification, processing, and transfer logic.

Test Environment Setup

Helper functions for test infrastructure:

CreateTestDir()        - Creates temporary directory with source/movies/shows/manager subdirs
CreateTestCfg()        - Creates test configuration pointing to test directories
CreateTestFiles()      - Recursively creates actual files on filesystem for integration tests

Usage Example

func TestProcessor(t *testing.T) {
    testDir := testutil.CreateTestDir(t)
    cfg := testutil.CreateTestCfg(testDir)

    movieFile := testutil.CreateTestMovieFile(nil)
    testutil.CreateTestFiles(movieFile, testDir)

    // Test processing logic...
}

Implementation

All test entries use consistent test values:

Title: ["TEST", "TITLE"]
Year: 2025
Resolution: "1080p"
Codec: "x264"
Source: "Remux"
Audio: "Atmos"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestBonusDir

func CreateTestBonusDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry

CreateTestBonusDir creates a test Entry representing a bonus content directory. Returns an Entry with BonusDir role containing the provided children. Updates child paths to be relative to "extras" directory.

func CreateTestBonusFile

func CreateTestBonusFile(parent *metadata.Entry) *metadata.Entry

CreateTestBonusFile creates a test Entry representing a bonus content file. Returns an Entry with BonusFile role and "Behind.The.Scenes" bonus metadata.

func CreateTestCfg

func CreateTestCfg(testDir string) config.Config

CreateTestCfg creates a test configuration pointing to subdirectories within testDir. Sets up paths for movies, shows, and manager directories with DryRun disabled.

func CreateTestDir

func CreateTestDir(t *testing.T) string

CreateTestDir creates a temporary directory structure for testing. Creates subdirectories: source, movies, shows, and manager. Returns the temporary directory path. Cleanup is automatic via t.TempDir().

func CreateTestEpFile

func CreateTestEpFile(parent *metadata.Entry) *metadata.Entry

CreateTestEpFile creates a test Entry representing a TV episode file. Returns an Entry with EpisodeFile role, S01E01 metadata, and video file properties.

func CreateTestFiles

func CreateTestFiles(root *metadata.Entry, testDir string)

CreateTestFiles recursively creates the actual filesystem structure for test entries. Creates directories and empty files based on the Entry tree structure. Updates entry source paths to absolute paths within testDir. Panics on filesystem errors.

func CreateTestMovieDir

func CreateTestMovieDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry

CreateTestMovieDir creates a test Entry representing a movie directory. Returns an Entry with MovieDir role for a 2025 release containing the provided children. Updates child paths to be relative to "test.title" directory.

func CreateTestMovieFile

func CreateTestMovieFile(parent *metadata.Entry) *metadata.Entry

CreateTestMovieFile creates a test Entry representing a movie file. Returns an Entry with MovieFile role, no season/episode metadata, and video file properties.

func CreateTestSeasonDir

func CreateTestSeasonDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry

CreateTestSeasonDir creates a test Entry representing a TV season directory. Returns an Entry with SeasonDir role for Season 1 containing the provided children. Updates child paths to be relative to "S01" directory.

func CreateTestSeriesDir

func CreateTestSeriesDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry

CreateTestSeriesDir creates a test Entry representing a TV series directory. Returns an Entry with SeriesDir role containing the provided children. Updates child paths to be relative to "test.title" directory.

func CreateTestSubDir

func CreateTestSubDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry

CreateTestSubDir creates a test Entry representing a subtitle directory. Returns an Entry with SubtitleDir role containing the provided children. Updates child paths to be relative to "subtitles" directory.

func CreateTestSubFile

func CreateTestSubFile(parent *metadata.Entry) *metadata.Entry

CreateTestSubFile creates a test Entry representing a subtitle file. Returns an Entry with SubtitleFile role, English language, and .srt extension.

func IntPtr

func IntPtr(i int) *int

IntPtr returns a pointer to the provided integer value. Helper function for creating int pointers in test structs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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