test

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const TEMPLATE = `` /* 217-byte string literal not displayed */

Variables

This section is empty.

Functions

func GatewayURL

func GatewayURL() *url.URL

func NewProxyClient

func NewProxyClient(proxyURL string) *http.Client

NewProxyClient creates an HTTP client that routes requests through an HTTP proxy.

func NewProxyTunnelClient

func NewProxyTunnelClient(proxyURL string) *http.Client

NewProxyTunnelClient creates an HTTP client that routes requests through an HTTP proxy using the CONNECT method, as described in RFC 7231 Section 4.3.6.

func RunWithSpecs

func RunWithSpecs(
	t *testing.T,
	tests SugarTests,
	required ...specs.Leaf,
)

func SubdomainGatewayURL

func SubdomainGatewayURL() *url.URL

Types

type AllOfExpectBuilder

type AllOfExpectBuilder struct {
	Expect_ []ExpectValidator `json:"expect,omitempty"`
}

func AllOf

func AllOf(expect ...ExpectValidator) AllOfExpectBuilder

func (AllOfExpectBuilder) Clone

Clone performs a deep clone of the AllOfExpectBuilder Note: if there are [check.Check]s used in the header or body components of the nested builders those are only shallowly cloned

func (AllOfExpectBuilder) Validate

func (e AllOfExpectBuilder) Validate(t *testing.T, res *http.Response, localReport Reporter)

type AnyOfExpectBuilder

type AnyOfExpectBuilder struct {
	Expect_ []ExpectBuilder `json:"expect,omitempty"`
}

func AnyOf

func AnyOf(expect ...ExpectBuilder) AnyOfExpectBuilder

func (AnyOfExpectBuilder) Clone

Clone performs a deep clone of the AnyOfExpectBuilder Note: if there are [check.Check]s used in the header or body components of the nested builders those are only shallowly cloned

func (AnyOfExpectBuilder) Validate

func (e AnyOfExpectBuilder) Validate(t *testing.T, res *http.Response, localReport Reporter)

type ExpectBuilder

type ExpectBuilder struct {
	StatusCode_     int             `json:"statusCode,omitempty"`
	StatusCodeFrom_ int             `json:"statusCodeFrom,omitempty"`
	StatusCodeTo_   int             `json:"statusCodeTo,omitempty"`
	Headers_        []HeaderBuilder `json:"headers,omitempty"`
	Body_           interface{}     `json:"body,omitempty"`
	Specs_          []string        `json:"specs,omitempty"`
}

func Expect

func Expect() ExpectBuilder

func ResponsesAreEqual

func ResponsesAreEqual() ExpectBuilder

func (ExpectBuilder) Body

func (e ExpectBuilder) Body(body interface{}) ExpectBuilder

func (ExpectBuilder) BodyWithHint

func (e ExpectBuilder) BodyWithHint(hint string, body interface{}) ExpectBuilder

func (ExpectBuilder) Bytes

func (e ExpectBuilder) Bytes(body string) ExpectBuilder

func (ExpectBuilder) Clone

func (e ExpectBuilder) Clone() ExpectValidator

Clone performs a deep clone of the ExpectBuilder Note: if there are [check.Check]s used in the inner header or body components those are only shallowly cloned

func (ExpectBuilder) Header

func (ExpectBuilder) Headers

func (e ExpectBuilder) Headers(hs ...HeaderBuilder) ExpectBuilder

func (ExpectBuilder) Spec

func (e ExpectBuilder) Spec(spec string) ExpectBuilder

func (ExpectBuilder) Specs

func (e ExpectBuilder) Specs(specs ...string) ExpectBuilder

func (ExpectBuilder) Status

func (e ExpectBuilder) Status(statusCode int) ExpectBuilder

func (ExpectBuilder) StatusBetween

func (e ExpectBuilder) StatusBetween(from, to int) ExpectBuilder

func (ExpectBuilder) Validate

func (e ExpectBuilder) Validate(t *testing.T, res *http.Response, localReport Reporter)

type ExpectValidator

type ExpectValidator interface {
	Validate(t *testing.T, res *http.Response, localReport Reporter)
	Clone() ExpectValidator
}

type ExpectsBuilder

type ExpectsBuilder struct {
	// contains filtered or unexported fields
}

func Responses

func Responses() ExpectsBuilder

func (ExpectsBuilder) HaveTheSamePayload

func (e ExpectsBuilder) HaveTheSamePayload() ExpectsBuilder

type HeaderBuilder

type HeaderBuilder struct {
	Key_   string                `json:"key,omitempty"`
	Value_ string                `json:"value,omitempty"`
	Check_ check.Check[[]string] `json:"check,omitempty"`
	Hint_  string                `json:"hint,omitempty"`
	Specs_ []string              `json:"specs,omitempty"`
	Not_   bool                  `json:"not,omitempty"`
}
func Header(key string, rest ...any) HeaderBuilder

func (HeaderBuilder) Checks

func (h HeaderBuilder) Checks(f func(string) bool) HeaderBuilder

func (HeaderBuilder) ChecksAll

func (h HeaderBuilder) ChecksAll(f func([]string) bool) HeaderBuilder

func (HeaderBuilder) Clone

func (h HeaderBuilder) Clone() HeaderBuilder

Clone performs a shallow clone of the HeaderBuilder Note: The Check field is an interface and as a result is just copied

func (HeaderBuilder) Contains

func (h HeaderBuilder) Contains(value string, rest ...any) HeaderBuilder

func (HeaderBuilder) Equals

func (h HeaderBuilder) Equals(value string, args ...any) HeaderBuilder

func (HeaderBuilder) Exists

func (h HeaderBuilder) Exists() HeaderBuilder

func (HeaderBuilder) Has

func (h HeaderBuilder) Has(values ...string) HeaderBuilder

func (HeaderBuilder) Hint

func (h HeaderBuilder) Hint(hint string) HeaderBuilder

func (HeaderBuilder) IsEmpty

func (h HeaderBuilder) IsEmpty() HeaderBuilder

func (HeaderBuilder) Matches

func (h HeaderBuilder) Matches(value string, rest ...any) HeaderBuilder

func (HeaderBuilder) Not

func (h HeaderBuilder) Not() HeaderBuilder

func (HeaderBuilder) Spec

func (h HeaderBuilder) Spec(spec string) HeaderBuilder

func (HeaderBuilder) Specs

func (h HeaderBuilder) Specs(specs ...string) HeaderBuilder

type ReportInput

type ReportInput struct {
	Req  *http.Request
	Res  *http.Response
	Err  error
	Test SugarTest
}

type Reporter

type Reporter func(t *testing.T, msg interface{}, rest ...interface{})

type RequestBuilder

type RequestBuilder struct {
	Method_          string            `json:"method,omitempty"`
	Path_            string            `json:"path,omitempty"`
	Proxy_           string            `json:"proxy,omitempty"`
	UseProxyTunnel_  bool              `json:"useProxyTunnel,omitempty"`
	Headers_         map[string]string `json:"headers,omitempty"`
	FollowRedirects_ bool              `json:"followRedirects,omitempty"`
	Query_           url.Values        `json:"query,omitempty"`
	Body_            []byte            `json:"body,omitempty"`
}

func Request

func Request() RequestBuilder

func Requests

func Requests(rs ...RequestBuilder) []RequestBuilder

func (RequestBuilder) Clone

func (r RequestBuilder) Clone() RequestBuilder

func (RequestBuilder) FollowRedirects

func (r RequestBuilder) FollowRedirects() RequestBuilder

func (RequestBuilder) Header

func (r RequestBuilder) Header(k, v string, rest ...any) RequestBuilder

func (RequestBuilder) Headers

func (r RequestBuilder) Headers(hs ...HeaderBuilder) RequestBuilder

func (RequestBuilder) Method

func (r RequestBuilder) Method(method string) RequestBuilder

func (RequestBuilder) Path

func (r RequestBuilder) Path(path string, args ...any) RequestBuilder

func (RequestBuilder) Proxy

func (r RequestBuilder) Proxy(path string, args ...any) RequestBuilder

func (RequestBuilder) Query

func (r RequestBuilder) Query(key, value string, args ...any) RequestBuilder

func (RequestBuilder) RemoveHeader added in v0.6.0

func (r RequestBuilder) RemoveHeader(hdr string) string

func (RequestBuilder) WithProxyTunnel

func (r RequestBuilder) WithProxyTunnel() RequestBuilder

type SugarTest

type SugarTest struct {
	Name      string
	Hint      string
	Spec      string
	Specs     []string
	Request   RequestBuilder
	Requests  []RequestBuilder
	Response  ExpectValidator
	Responses ExpectsBuilder
}

func (*SugarTest) AllSpecs

func (s *SugarTest) AllSpecs() []string

type SugarTests

type SugarTests []SugarTest

func (SugarTests) Append

func (s SugarTests) Append(tests ...SugarTest) SugarTests

Jump to

Keyboard shortcuts

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