expectation

package
v0.0.0-...-8eaeb25 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback struct {
	Request any    `json:"request"`
	Timeout int    `json:"timeout"`
	Url     string `json:"url"`
	Method  string `json:"method"`
}
type Cookie struct {
	Name  string `json:"name"`
	Value string `json:"value"`

	Path       string    `json:"path"`       // optional
	Domain     string    `json:"domain"`     // optional
	Expires    time.Time `json:"expires"`    // optional
	RawExpires string    `json:"rawExpires"` // for reading cookies only

	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
	// MaxAge>0 means Max-Age attribute present and given in seconds
	MaxAge   int      `json:"maxAge"`
	Secure   bool     `json:"secure"`
	HttpOnly bool     `json:"httpOnly"`
	SameSite SameSite `json:"sameSite"`
	Raw      string   `json:"raw"`
	Unparsed []string `json:"unparsed"` // Raw text of unparsed attribute-value pairs
}

struct taking from net/http package

type CueMatcher

type CueMatcher[T any] struct {
	MatchExpression string `json:"match"`
	Value           *T     `json:"value"` // pointers allows a match value to be missing
}

func (CueMatcher[T]) GetValue

func (m CueMatcher[T]) GetValue() *T

type Expectation

type Expectation struct {
	Priority int       `json:"priority"`
	Request  Request   `json:"request"`
	Response Response  `json:"response"`
	Callback *Callback `json:"callback"`
	// MatchRules MatchRules `json:"-"`
	ExpectationType ExpectationType `json:"-"`
}

type ExpectationError

type ExpectationError struct {
	Expectation
	ExpectationFieldErrors []ExpectationFieldError
}

func (ExpectationError) Error

func (e ExpectationError) Error() string

type ExpectationFieldError

type ExpectationFieldError struct {
	FieldName string
	Err       error
}

type ExpectationType

type ExpectationType string
const (
	Default ExpectationType = "DEFAULT"
	Custom  ExpectationType = "CUSTOM"
)

type Expectations

type Expectations struct {
	Expectations []Expectation `json:"expectations"`
}

type Request

type Request struct {
	Path       string             `json:"path"`
	Method     string             `json:"method"`
	Body       any                `json:"body"`
	Parameters *RequestParameters `json:"params"`
	Headers    map[string]any     `json:"headers"`
	Cookies    []any              `json:"cookies"`
}

func (*Request) Route

func (r *Request) Route() schema.Route

func (*Request) RouteWithParsedPath

func (r *Request) RouteWithParsedPath() (*schema.Route, error)

type RequestParameters

type RequestParameters struct {
	Path  map[string]any `json:"path"`
	Query map[string]any `json:"query"`
}

type Response

type Response struct {
	Body          any                     `json:"body"`
	GeneratedBody dstruct.GeneratedStruct `json:"-"`
	Status        int                     `json:"status"`
	Headers       *map[string][]string    `json:"headers"`
	Cookies       *[]Cookie               `json:"cookies"`
}

type SameSite

type SameSite int
const (
	SameSiteDefaultMode SameSite = iota + 1
	SameSiteLaxMode
	SameSiteStrictMode
	SameSiteNoneMode
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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