tests

package
v1.0.0-beta.23 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2021 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClockFromContext

func ClockFromContext(ctx context.Context) clockwork.FakeClock

ClockFromContext returns clock or panics.

func ConfigureSteps

func ConfigureSteps(s *gobdd.Suite)

ConfigureSteps on given suite.

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 GetCleanup

func GetCleanup(ctx gobdd.Context) map[string]func()

GetCleanup functions.

func GetCtx

func GetCtx(ctx gobdd.Context) context.Context

GetCtx returns Go context.

func GetData

func GetData(ctx gobdd.Context) map[string]interface{}

GetData returns feature context.

func GetIgnoredTags

func GetIgnoredTags() []string

GetIgnoredTags returns list of ignored tags.

func GetJSONResponse

func GetJSONResponse(ctx gobdd.Context) interface{}

GetJSONResponse returns request response.

func GetRequestArguments

func GetRequestArguments(ctx gobdd.Context) []interface{}

GetRequestArguments helps to build a request.

func GetRequestParameters

func GetRequestParameters(ctx gobdd.Context) map[string]interface{}

GetRequestParameters helps to build a request.

func GetRequestsUndo

func GetRequestsUndo(ctx gobdd.Context, operationID string) (func([]reflect.Value) func(), error)

GetRequestsUndo gets map with undo function for each request.

func GetResponse

func GetResponse(ctx gobdd.Context) []reflect.Value

GetResponse returns request response.

func GetResponseStatusCode

func GetResponseStatusCode(resp []reflect.Value) (int, error)

GetResponseStatusCode returns request response status code.

func GetT

func GetT(ctx gobdd.Context) *testing.T

GetT returns stored reference to the testing object.

func IsCIRun

func IsCIRun() bool

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

func LoadRequestsUndo

func LoadRequestsUndo(file string) (map[string]UndoAction, error)

LoadRequestsUndo load undo configuration.

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 RunCleanup

func RunCleanup(ctx gobdd.Context)

RunCleanup executes cleanup functions in controlled ordered based on registered keys.

func SecurePath

func SecurePath(path string) string

SecurePath replaces all dangerous characters in the path.

func SetAPI

func SetAPI(ctx gobdd.Context, value interface{})

SetAPI sets client API.

func SetCleanup

func SetCleanup(ctx gobdd.Context, value map[string]func())

SetCleanup functions.

func SetClient

func SetClient(ctx gobdd.Context, value interface{})

SetClient sets client reflection.

func SetClock

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

SetClock stores current time in .freeze file.

func SetCtx

func SetCtx(ctx gobdd.Context, value context.Context)

SetCtx sets Go context in BDD context.

func SetData

func SetData(ctx gobdd.Context, value map[string]interface{})

SetData sets feature context.

func SetFixtureData

func SetFixtureData(ctx gobdd.Context)

SetFixtureData sets the fixture data in BDD context

func SetRequestsUndo

func SetRequestsUndo(ctx gobdd.Context, value map[string]UndoAction)

SetRequestsUndo sets map with undo function for each request.

func SnakeToCamelCase

func SnakeToCamelCase(snake string) (camel string)

SnakeToCamelCase converts snake_case to SnakeCase.

func Templated

func Templated(t gobdd.StepTest, data interface{}, source string) string

Templated replaces {{ path }} in source with value from data[path].

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 GivenStep

type GivenStep struct {
	Tag         string               `json:"tag"`
	Key         string               `json:"key"`
	Step        string               `json:"step"`
	OperationID string               `json:"operationId"`
	Parameters  []operationParameter `json:"parameters"`
	Source      *string              `json:"source"`
}

GivenStep defines a step.

func LoadGivenSteps

func LoadGivenSteps(file string) ([]GivenStep, error)

LoadGivenSteps load undo configuration.

func (GivenStep) RegisterSuite

func (s GivenStep) RegisterSuite(suite *gobdd.Suite)

RegisterSuite adds step implementation.

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.

type UndoAction

type UndoAction struct {
	Tag  string `json:"tag"`
	Undo *struct {
		Type        string `json:"type"`
		OperationID string `json:"operationId"`
		Parameters  []struct {
			Name   string `json:"name"`
			Source string `json:"source"`
		} `json:"parameters"`
	} `json:"undo"`
}

UndoAction describes undo action.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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