testutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package testutil provides utilities for testing.

Index

Constants

View Source
const (
	// ErrMissingEnvVar is returned when an environment variable is missing.
	ErrMissingEnvVar xerrors.Error = "missing environment variable"

	// ErrTestClient is returned when the test client fails to initialize.
	ErrTestClient xerrors.Error = "failed to initialize test client"
)
View Source
const MockServerAddr string = "localhost:62769"

MockServerAddr is the address of the mock server.

Variables

This section is empty.

Functions

func ReadFile added in v0.3.0

func ReadFile(t *testing.T, name string) (file []byte)

ReadFile reads the named file and either returns its contents or fails the test.

func SetupClient

func SetupClient() (client *bunnystorage.Client, err error)

SetupClient sets up a test client for integration tests.

The following environment variables are required: - BUNNY_STORAGE_ZONE - BUNNY_READ_API_KEY - BUNNY_WRITE_API_KEY

The test will fail if any of them are empty or not set.

func SetupFile

func SetupFile(t *testing.T) (name string, size int64, err error)

SetupFile sets up a simple text file for use in integration tests.

func SetupMockClient added in v0.3.0

func SetupMockClient(t *testing.T) *bunnystorage.Client

SetupMockClient sets up a mock client for mocking tests.

func SetupMockServer added in v0.3.0

func SetupMockServer(t *testing.T) (mux *http.ServeMux, teardown func())

SetupMockServer sets up a mock server for mocking tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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