testutil

package
v0.1.200 Latest Latest
Warning

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

Go to latest
Published: May 9, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgSent     = "| Sent 🌎     |"
	MstReceived = "| Received 📮 |"
)

Variables

This section is empty.

Functions

func Assert

func Assert(t *testing.T, r *http.Response, opts AssertionOptions)

Assert verifies that the response status is within the accepted statuses.

func Extract

func Extract[T comparable](t *testing.T, body io.Reader, u contract.Unmarshaler, field string, to *[]T, opts ExtractionOptions)

func FailOnError

func FailOnError(t *testing.T, err error)

FailOnError fails the test if the error is not nil.

func Log

func Log(ctx context.Context, t *testing.T, logger contract.LogOperator, responseBody io.Reader, opts LogOptions) error

Log creates a detailed log entry for integration tests requests and responses.

Types

type AssertionOption

type AssertionOption func(*AssertionOptions)

func WithExpected

func WithExpected(expected []int) AssertionOption

type AssertionOptions

type AssertionOptions struct {
	Expected []int
}

func ApplyAssertionOptions

func ApplyAssertionOptions(opts *AssertionOptions, modifiers ...AssertionOption) AssertionOptions

type ExtractionOption

type ExtractionOption func(*ExtractionOptions)

func WithBypass

func WithBypass(bypass bool) ExtractionOption

WithBypass specifies whether to bypass the extraction.

type ExtractionOptions

type ExtractionOptions struct {
	Bypass bool
}

func ApplyExtractionOptions

func ApplyExtractionOptions(opts *ExtractionOptions, modifiers ...ExtractionOption) ExtractionOptions

type LogOption

type LogOption func(*LogOptions)

func WithCollection

func WithCollection(collectionName string) LogOption

func WithMethod

func WithMethod(method string) LogOption

func WithTestCaseName

func WithTestCaseName(testCaseName string) LogOption

func WithTestDescription

func WithTestDescription(testDescription string) LogOption

func WithTestMessage

func WithTestMessage(testMessage string) LogOption

func WithURL

func WithURL(url string) LogOption

type LogOptions

type LogOptions struct {
	Method          string
	URL             string
	TestMessage     string
	TestCaseName    string
	Collection      string
	TestDescription string
}

func ApplyLogOptions

func ApplyLogOptions(opts *LogOptions, modifiers ...LogOption) LogOptions

Jump to

Keyboard shortcuts

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