tests

package module
v0.0.0-...-2ae8859 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("Unable to find the key")

ErrNotFound is returned when the key didn't match

Functions

func ClockFromContext

func ClockFromContext(ctx context.Context) clockwork.FakeClock

ClockFromContext returns clock or panics.

func CompareAsJSON

func CompareAsJSON(first, second io.Reader) (bool, error)

CompareAsJSON returns true if JSON strings serialize into same values.

func ConfigureTracer

func ConfigureTracer(m *testing.M)

ConfigureTracer starts the tracer.

func FilterInteraction

func FilterInteraction(i *cassette.Interaction) error

FilterInteraction removes secret arguments from the URL.

func IsCIRun

func IsCIRun() bool

IsCIRun returns true if the CI environment variable is set to "true"

func LookupStringI

func LookupStringI(i interface{}, path string) (reflect.Value, error)

LookupStringI returnes the value found at the given path

func MatchInteraction

func MatchInteraction(r *http.Request, i cassette.Request) bool

MatchInteraction checks if the request matches a store request in the given cassette.

func ReadFixture

func ReadFixture(path string) (string, error)

ReadFixture opens the file at path and returns the contents as a string

func Recorder

func Recorder(ctx context.Context, name string) (*recorder.Recorder, error)

Recorder intercepts HTTP requests.

func RestoreClock

func RestoreClock(path string) (clockwork.FakeClock, error)

RestoreClock restore current time from .freeze file.

func Retry

func Retry(interval time.Duration, count int, call func() bool) error

Retry calls the call function for count times every interval while it returns false

func SecurePath

func SecurePath(path string) string

SecurePath replaces all dangerous characters in the path.

func SetClock

func SetClock(path string) (clockwork.FakeClock, error)

SetClock stores current time in .freeze file.

func UniqueEntityName

func UniqueEntityName(ctx context.Context, t *testing.T) *string

UniqueEntityName will return a unique string that can be used as a title/description/summary/... of an API entity.

func WithClock

func WithClock(ctx context.Context, path string) (context.Context, error)

WithClock sets clock to context.

func WithTestSpan

func WithTestSpan(ctx context.Context, t *testing.T) (context.Context, func())

WithTestSpan starts new span with test information.

func WithUniqueSurrounding

func WithUniqueSurrounding(ctx context.Context, name string) string

WithUniqueSurrounding will wrap a string that can be used as a title/description/summary/... of an API entity.

func WrapRoundTripper

func WrapRoundTripper(rt http.RoundTripper, opts ...ddhttp.RoundTripperOption) http.RoundTripper

WrapRoundTripper includes tracing information.

Types

type Assertions

type Assertions struct {
	require.Assertions
}

Assertions wrapper

func Assert

func Assert(ctx context.Context, t *testing.T) *Assertions

Assert wraps context and testing object.

type RecordingMode

type RecordingMode string

RecordingMode defines valid usage of cassette recorder

const (
	ModeIgnore    RecordingMode = "none"
	ModeReplaying RecordingMode = "false"
	ModeRecording RecordingMode = "true"
)

Valid usage modes for cassette recorder

func GetRecording

func GetRecording() RecordingMode

GetRecording returns the value of RECORD environment variable

type TestingT

type TestingT struct {
	*testing.T
	// contains filtered or unexported fields
}

TestingT keeps track of a context.

func (*TestingT) Errorf

func (t *TestingT) Errorf(format string, args ...interface{})

Errorf format error message.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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