api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

package picker provided structures and method to manage injected variable system for Godog.

It allows an user to pick value into a store and inject them in steps through a variable replacement.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMatch       = errors.New("actual value does not match expected")
	ErrNoPath        = errors.New("path does not exists in object")
	ErrNotFullyMatch = errors.New("expected values to be fully matched but it was not")
)
View Source
var (
	ErrNoBody     = errors.New("impossible to retrieve data from empty response body")
	ErrUnknownKey = errors.New("unknown key")
)
View Source
var ErrNoRequest = errors.New("trying to emit empty request")

Functions

func Debug

func Debug()

Debug activate debug logs.

func NoLog

func NoLog()

NoLog disable logging under Fatal level.

func Reset

func Reset() error

Reset matcher instance.

func ResetLog

func ResetLog()

ResetLog activate debug logs.

Types

type Client

type Client struct {
	Response *Response
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cli *http.Client) (*Client, error)

func (*Client) EmitRequest

func (cli *Client) EmitRequest(req RequestPreparation) (err error)

func (Client) HasCookie

func (cli Client) HasCookie(cookieName string) bool

func (*Client) Reset

func (cli *Client) Reset()

func (*Client) SetFollowRedirection

func (cli *Client) SetFollowRedirection(follow bool)

func (*Client) SetTrace

func (cli *Client) SetTrace(activate bool)

type RequestPreparation

type RequestPreparation struct {
	AllowCookie bool
	JSONBody    *string
	FORMBody    map[string]formElement
	Headers     *http.Header
	Cookies     []*http.Cookie
	Arguments   map[string]string
	Endpoint    string
	Method      string
}

func PrepareRequest

func PrepareRequest(withCookie bool) RequestPreparation

func (RequestPreparation) AddArgument

func (request RequestPreparation) AddArgument(key, value string) RequestPreparation

func (RequestPreparation) AddCookie

func (request RequestPreparation) AddCookie(key, val string, options *messages.PickleStepArgument_PickleTable) (RequestPreparation, error)

nolint: gocyclo

func (RequestPreparation) AddHeader

func (request RequestPreparation) AddHeader(key, value string) RequestPreparation

func (RequestPreparation) AllowCookies

func (request RequestPreparation) AllowCookies(allow bool) RequestPreparation

func (RequestPreparation) Empty

func (request RequestPreparation) Empty() bool

func (RequestPreparation) GenerateRequest

func (request RequestPreparation) GenerateRequest(jar http.CookieJar) (*http.Request, error)

Generate request

func (RequestPreparation) ResetArguments

func (request RequestPreparation) ResetArguments() RequestPreparation

func (RequestPreparation) ResetBody

func (request RequestPreparation) ResetBody() RequestPreparation

func (RequestPreparation) ResetCookies

func (request RequestPreparation) ResetCookies() RequestPreparation

func (RequestPreparation) ResetHeader

func (request RequestPreparation) ResetHeader() RequestPreparation

func (RequestPreparation) SetEndpoint

func (request RequestPreparation) SetEndpoint(endpoint string) RequestPreparation

func (RequestPreparation) SetFORMBody

func (request RequestPreparation) SetFORMBody(body *godog.Table) RequestPreparation

func (RequestPreparation) SetJSONBody

func (request RequestPreparation) SetJSONBody(body *godog.DocString) RequestPreparation

func (RequestPreparation) SetMethod

func (request RequestPreparation) SetMethod(method string) RequestPreparation

type Response

type Response struct {
	Body    []byte
	Cookies map[string]*http.Cookie
	Headers http.Header
	Status  int
}

func NewResponse

func NewResponse(status int, body []byte, cookies []*http.Cookie, headers http.Header) *Response

func (Response) GetCookie

func (r Response) GetCookie(cookieName string) *http.Cookie

func (Response) HTMLContain

func (r Response) HTMLContain(expectedBody *godog.Table) error

func (Response) HTMLResemble

func (r Response) HTMLResemble(expectedBody *godog.DocString) error

func (Response) HasCookie

func (r Response) HasCookie(cookieName string) bool

func (Response) HasEmptyBody

func (r Response) HasEmptyBody() bool

func (Response) HasStatus

func (r Response) HasStatus(status int) bool

func (Response) HeaderMatches

func (r Response) HeaderMatches(expected *godog.Table) error

func (Response) JSONContains

func (r Response) JSONContains(fully bool, expected *godog.Table) error

func (Response) JSONResemble

func (r Response) JSONResemble(expectedBody *godog.DocString) error

func (Response) RetrieveHTMLAttribute

func (r Response) RetrieveHTMLAttribute(tag, attribute string, filters *godog.Table) (string, error)

func (Response) RetrieveHeader

func (r Response) RetrieveHeader(key string) string

func (Response) RetrieveJSON

func (r Response) RetrieveJSON(key string) (interface{}, error)

Jump to

Keyboard shortcuts

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