xtesting

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package xtesting provides functions and utilities for testing the Cloudcraft SDK.

Index

Constants

View Source
const ErrGreaterThanZero xerrors.Error = "value must be greater than zero"

ErrGreaterThanZero is returned when a given value is not greater than zero.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(t *testing.T, name string) string

GetEnv returns the value of the environment variable with the given name or fails the test if the variable is not set.

func ParseTime

func ParseTime(t *testing.T, str string) time.Time

ParseTime returns the time parsed from the given string or fails the test if the string is not a valid time.

func RandomString

func RandomString(t *testing.T, r io.Reader, n int) (string, error)

RandomString returns a random string of length n that is safe for use in a URL.

func ReadFile

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

ReadFile reads the named file and returns its contents.

func SetupLiveClient

func SetupLiveClient(t *testing.T) *cloudcraft.Client

SetupLiveClient sets up a test API client for unit tests against the live Cloudcraft API.

The following environment variables are required: - CLOUDCRAFT_TEST_API_KEY

If any of these variables are not set, SetupLiveClient will fail the test.

func SetupMockClient

func SetupMockClient(t *testing.T, endpoint *url.URL) *cloudcraft.Client

SetupMockClient sets up a test API client for unit tests against a mock version of the Cloudcraft API.

func UniqueName

func UniqueName(t *testing.T) string

UniqueName returns an unique name that can be used as a resource name in Cloudcraft.

Types

This section is empty.

Jump to

Keyboard shortcuts

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