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 ¶
- func CreateTestBonusDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry
- func CreateTestBonusFile(parent *metadata.Entry) *metadata.Entry
- func CreateTestCfg(testDir string) config.Config
- func CreateTestDir(t *testing.T) string
- func CreateTestEpFile(parent *metadata.Entry) *metadata.Entry
- func CreateTestFiles(root *metadata.Entry, testDir string)
- func CreateTestMovieDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry
- func CreateTestMovieFile(parent *metadata.Entry) *metadata.Entry
- func CreateTestSeasonDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry
- func CreateTestSeriesDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry
- func CreateTestSubDir(parent *metadata.Entry, children ...*metadata.Entry) *metadata.Entry
- func CreateTestSubFile(parent *metadata.Entry) *metadata.Entry
- func IntPtr(i int) *int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTestBonusDir ¶
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 ¶
CreateTestBonusFile creates a test Entry representing a bonus content file. Returns an Entry with BonusFile role and "Behind.The.Scenes" bonus metadata.
func CreateTestCfg ¶
CreateTestCfg creates a test configuration pointing to subdirectories within testDir. Sets up paths for movies, shows, and manager directories with DryRun disabled.
func CreateTestDir ¶
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 ¶
CreateTestEpFile creates a test Entry representing a TV episode file. Returns an Entry with EpisodeFile role, S01E01 metadata, and video file properties.
func CreateTestFiles ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
CreateTestSubFile creates a test Entry representing a subtitle file. Returns an Entry with SubtitleFile role, English language, and .srt extension.
Types ¶
This section is empty.