test

package
v0.0.0-...-940c498 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultURL = "http://127.0.0.1:10000"

Variables

This section is empty.

Functions

This section is empty.

Types

type Actual

type Actual struct {
	ResponseHeaders http.Header
	RequestHeaders  http.Header
	Body            string
}

type Case

type Case struct {
	Name   string `json:"name"`
	Input  Input  `json:"input"`
	Expect Expect `json:"expect"`
	// contains filtered or unexported fields
}

func (Case) Run

func (c Case) Run(t *testing.T, opts ...Options)

type Expect

type Expect struct {
	RequestHeaders  []HeaderMatch `json:"requestHeaders"`
	ResponseHeaders []HeaderMatch `json:"responseHeaders"`
	ResponseBody    *StringMatch  `json:"responseBody"`
}

func (Expect) Assert

func (e Expect) Assert(t *testing.T, actual Actual) error

type HeaderMatch

type HeaderMatch struct {
	Name        *string     `json:"name"`
	Exact       *string     `json:"exact"`
	Absent      *bool       `json:"absent"`
	Regex       *string     `json:"regex"`
	MatchAction MatchAction `json:"matchAction"`
}

TODO(cainelli): Use the generic StringMatch

func (HeaderMatch) Assert

func (hm HeaderMatch) Assert(t *testing.T, headers http.Header) bool

func (*HeaderMatch) MatchType

func (hm *HeaderMatch) MatchType() string

func (*HeaderMatch) MatchValue

func (hm *HeaderMatch) MatchValue() string

type HeaderValue

type HeaderValue struct {
	Key   string `json:"name"`
	Value string `json:"value"`
}

type Headers

type Headers []HeaderValue

func (Headers) Get

func (headers Headers) Get(key string) string

type Input

type Input struct {
	Headers Headers `json:"headers"`
}

type MatchAction

type MatchAction string
const (
	MatchActionFirst MatchAction = "FIRST"
	MatchActionAny   MatchAction = "ANY"
	MatchActionAll   MatchAction = "ALL"
)

type Options

type Options interface {
	// contains filtered or unexported methods
}

func WithRetry

func WithRetry(r Retry) Options

func WithURL

func WithURL(url string) Options

type Retry

type Retry struct {
	MaxAttempts int           // Maximum number of retries
	WaitMin     time.Duration // Minimum time to wait
	WaitMax     time.Duration // Maximum time to wait

	// PostHook specifies a policy for handling retries. It is called
	// following each request with the response and error values returned by
	// the http call. If PostHook returns false, the Client stops retrying
	PostHook func(Actual) bool
}

type StringMatch

type StringMatch struct {
	Exact       *string     `json:"exact"`
	Absent      *bool       `json:"absent"`
	Regex       *string     `json:"regex"`
	MatchAction MatchAction `json:"matchAction"`
}

func (StringMatch) Assert

func (sm StringMatch) Assert(t *testing.T, values ...string) bool

func (*StringMatch) MatchType

func (sm *StringMatch) MatchType() string

func (*StringMatch) MatchValue

func (sm *StringMatch) MatchValue() string

type TestCases

type TestCases []Case

func Load

func Load(t *testing.T, path string) TestCases

func LoadTemplate

func LoadTemplate(t *testing.T, path string, templateData any) TestCases

func (TestCases) Run

func (cases TestCases) Run(t *testing.T, opts ...Options)

Directories

Path Synopsis
containers

Jump to

Keyboard shortcuts

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