package testutil
import "git.sr.ht/~jamesponddotco/bunnystorage-go/internal/testutil"
Package testutil provides utilities for testing.
Index ¶
- Constants
- func ReadFile(t *testing.T, name string) (file []byte)
- func SetupClient() (client *bunnystorage.Client, err error)
- func SetupFile(t *testing.T) (name string, size int64, err error)
- func SetupMockClient(t *testing.T) *bunnystorage.Client
- func SetupMockServer(t *testing.T) (mux *http.ServeMux, teardown func())
Constants ¶
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" )
const MockServerAddr string = "localhost:62769"
MockServerAddr is the address of the mock server.
Functions ¶
func ReadFile ¶
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 ¶
SetupFile sets up a simple text file for use in integration tests.
func SetupMockClient ¶
SetupMockClient sets up a mock client for mocking tests.
func SetupMockServer ¶
SetupMockServer sets up a mock server for mocking tests.
Source Files ¶
- Version
- v0.3.0 (latest)
- Published
- Jul 11, 2023
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 1 day ago –
Tools for package owners.