testutil

package
v1.64.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MPL-2.0 Imports: 12 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

View Source
const (
	// A null in the middle triggers an error if SQLite stores data as text instead of blob.
	GreetingFileContents = "hello,\x00world\n"
	GreetingFileName     = "greeting"
)

Variables

View Source
var Greeting = Torrent{
	Files: []File{{
		Data: GreetingFileContents,
	}},
	Name: GreetingFileName,
}

Functions

func CreateDummyTorrentData

func CreateDummyTorrentData(dirName string) string

func ExportStatusWriter

func ExportStatusWriter(sw StatusWriter, path string, t testing.TB) (release func())

func GreetingMetaInfo

func GreetingMetaInfo() *metainfo.MetaInfo

func GreetingTestTorrent

func GreetingTestTorrent() (tempDir string, metaInfo *metainfo.MetaInfo)

Gives a temporary directory containing the completed "greeting" torrent, and a corresponding metainfo describing it. The temporary directory can be cleaned away with os.RemoveAll.

Types

type File

type File struct {
	Name string
	Data string
}

type StatusWriter

type StatusWriter interface {
	WriteStatus(io.Writer)
}

type Torrent

type Torrent struct {
	Files []File
	Name  string
}

High-level description of a torrent for testing purposes.

func (*Torrent) Generate added in v1.59.0

func (t *Torrent) Generate(pieceLength int64) (mi metainfo.MetaInfo, info metainfo.Info)

Create an info and metainfo with bytes set for the torrent with the provided piece length.

func (*Torrent) GetFile

func (t *Torrent) GetFile(name string) *File

func (*Torrent) Info

func (t *Torrent) Info(pieceLength int64) metainfo.Info

func (*Torrent) IsDir

func (t *Torrent) IsDir() bool

Jump to

Keyboard shortcuts

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