testsuite

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package testsuite is a collection of utilities for integration/unit testing in golang.

Index

Constants

This section is empty.

Variables

View Source
var ProjectName = "go-testsuite"

ProjectName is the prefix used in the test temp files

Functions

func SharedDir

func SharedDir(t *testing.T, id string) *paths.Path

SharedDir returns the shared downloads directory.

Types

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

Environment is a test environment for the test suite.

func NewEnvironment

func NewEnvironment(t *testing.T) *Environment

NewEnvironment creates a new test environment.

func (*Environment) CleanUp

func (e *Environment) CleanUp()

CleanUp removes the test environment.

func (*Environment) Download

func (e *Environment) Download(rawURL string) *paths.Path

Download downloads a file from a URL and returns the path to the downloaded file. The file is saved and cached in a shared downloads directory. If the file already exists, it is not downloaded again.

func (*Environment) Extract

func (e *Environment) Extract(archive *paths.Path) *paths.Path

Extract extracts a tarball to a directory named as the archive with the "_content" suffix added. Returns the path to the directory.

func (*Environment) HTTPServeFile

func (env *Environment) HTTPServeFile(port uint16, path *paths.Path) *url.URL

HTTPServeFile spawn an http server that serve a single file. The server is started on the given port. The URL to the file and a cleanup function are returned.

func (*Environment) RegisterCleanUpCallback

func (e *Environment) RegisterCleanUpCallback(newCleanUp func())

RegisterCleanUpCallback adds a clean up function to the clean up chain

func (*Environment) RootDir

func (e *Environment) RootDir() *paths.Path

RootDir returns the root dir of the environment.

func (*Environment) SharedDownloadsDir

func (e *Environment) SharedDownloadsDir() *paths.Path

SharedDownloadsDir return the shared directory for downloads

func (*Environment) T

func (e *Environment) T() *testing.T

T returns the testing environment

Jump to

Keyboard shortcuts

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