testhelper

package
v0.0.0-...-86cb477 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package testhelper provides shared functionality and constants to be used in Discovery tests. It should only be imported by test files.

Index

Constants

View Source
const (
	// MITLicense is the contents of the MIT license. It is detectable by the
	// licensecheck package, and is considered redistributable.
	MITLicense = `` /* 1049-byte string literal not displayed */

	// BSD0License is the contents of the BSD-0-Clause license. It is detectable
	// by the licensecheck package, and is considered redistributable.
	BSD0License = `` /* 633-byte string literal not displayed */

	// UnknownLicense is not detectable by the licensecheck package.
	UnknownLicense = `THIS IS A LICENSE THAT I JUST MADE UP. YOU CAN DO WHATEVER YOU WANT WITH THIS CODE, TRUST ME.`
)

Variables

This section is empty.

Functions

func CompareWithGolden

func CompareWithGolden(t *testing.T, got, filename string, update bool)

func CreateTestDirectory

func CreateTestDirectory(files map[string]string) (_ string, err error)

CreateTestDirectory creates a directory to hold a module when testing local fetching, and returns the directory.

func SetupTestClientAndServer

func SetupTestClientAndServer(handler http.Handler) (*http.Client, *httptest.Server, func())

SetupTestClientAndServer returns a *httpClient that can be used to stub requests to remote hosts by redirecting all requests that the client makes to a httptest.Server. with the given handler. It also disables TLS verification.

func TestDataPath

func TestDataPath(rel string) string

TestDataPath returns a path corresponding to a path relative to the calling test file. For convenience, rel is assumed to be "/"-delimited.

It panics on failure.

func WriteTxtarToTempDir

func WriteTxtarToTempDir(t *testing.T, data string) (string, map[string]string)

WriteTxtarToTempDir parses data as a txtar archive, and writes the resulting files to a new tempdir created with t.TempDir(). It returns the temp directory and files that were unpacked.

func ZipContents

func ZipContents(contents map[string]string) ([]byte, error)

ZipContents creates an in-memory zip of the given contents.

Types

This section is empty.

Jump to

Keyboard shortcuts

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