testutil

package
v0.0.0-...-7571207 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package testutil contains stuff for testing torrent-related behaviour.

"greeting" is a single-file torrent of a file called "greeting" that "contains "hello, world\n".

Index

Constants

View Source
const (
	GreetingFileContents = "hello, world\n"
	GreetingFileName     = "greeting"
)

various constants.

Variables

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

Greeting torrent

Functions

func Autodir

func Autodir(t tt) string

Autodir generates random directory under the testing temp dir.

func CreateDummyTorrentData

func CreateDummyTorrentData(dirName string) string

CreateDummyTorrentData in the given directory.

func ExportStatusWriter

func ExportStatusWriter(sw StatusWriter, path string) (release func())

func GreetingMetaInfo

func GreetingMetaInfo() *metainfo.MetaInfo

GreetingMetaInfo ...

func GreetingTestTorrent

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

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

func NewBadStorage

func NewBadStorage() storage.ClientImpl

NewBadStorage used for tests.

func RandomDataTorrent

func RandomDataTorrent(dir string, n int64) (d *os.File, err error)

RandomDataTorrent generates a torrent from random data.

Types

type File

type File struct {
	Name string
	Data string
}

File ...

type StatusWriter

type StatusWriter interface {
	WriteStatus(io.Writer)
}

type Torrent

type Torrent struct {
	Files []File
	Name  string
}

Torrent ...

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

func (*Torrent) Metainfo

func (t *Torrent) Metainfo(pieceLength int64) *metainfo.MetaInfo

Jump to

Keyboard shortcuts

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