nzbbuild

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package nzbbuild provides helpers for constructing NZB objects and writing them to temporary files in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(files ...File) *nzbparser.Nzb

Build assembles a *nzbparser.Nzb from the provided file descriptions. The resulting object can be passed to nzbparser.Write for disk serialisation or used directly with any in-process helper that accepts *nzbparser.Nzb.

func WriteTemp

func WriteTemp(t *testing.T, n *nzbparser.Nzb, name string) string

WriteTemp renders n to a .nzb file inside t.TempDir() and returns its path. name should be the base filename without extension (e.g. "My.Release.2024").

Types

type File

type File struct {
	// Subject is used as both the XML subject attribute and the parsed filename.
	Subject string
	// Groups defaults to ["alt.binaries.test"] when nil.
	Groups   []string
	Segments []Segment
	// Date is the Unix timestamp for the file entry (0 is fine for tests).
	Date int
}

File describes one <file> entry in an NZB.

type Segment

type Segment struct {
	// ID is the NNTP message-ID (e.g. "test-seg-001@fake").
	ID string
	// Bytes is the declared segment size as it would appear in the NZB
	// <segment bytes="N"> attribute.  Set this higher than the real decoded
	// payload to simulate yEnc/article overhead.
	Bytes int
}

Segment describes one <segment> entry in an NZB file.

Jump to

Keyboard shortcuts

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