gdutils

package module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: MIT Imports: 36 Imported by: 1

README

gdutils Go Reference Coverage

GDUTILS

Simple library with methods useful for e2e testing of HTTP(s) API using JSON/YAML/XML.

Library is suitable for steps in godog framework.

Downloading

go get github.com/pawelWritesCode/gdutils

Skeleton that allows to write e2e HTTP API tests using godog & gdutils almost instantly with minimal configuration. https://github.com/pawelWritesCode/godog-example-setup

Available methods:
NAME DESCRIPTION
Sending HTTP(s) requests:
ISendRequestToWithBodyAndHeaders Sends HTTP(s) request with provided body and headers.
IPrepareNewRequestToAndSaveItAs Prepare HTTP(s) request
ISetFollowingHeadersForPreparedRequest Sets provided headers for previously prepared request
ISetFollowingFormForPreparedRequest Sets provided form for previously prepared request
ISetFollowingCookiesForPreparedRequest Sets provided cookies for previously prepared request
ISetFollowingBodyForPreparedRequest Sets body for previously prepared request
ISendRequest Sends previously prepared HTTP(s) request
Random data generation:
IGenerateARandomIntInTheRangeToAndSaveItAs Generates random integer from provided range and save it under provided cache key
IGenerateARandomFloatInTheRangeToAndSaveItAs Generates random float from provided range and save it under provided cache key
IGenerateARandomRunesInTheRangeToAndSaveItAs Creates generator for random strings from provided charset in provided range
IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAs Creates generator for random sentence from provided charset in provided range
IGetTimeAndTravelByAndSaveItAs Accepts time object and move in time by given time interval
IGenerateCurrentTimeAndTravelByAndSaveItAs Creates current time object and move in time by given time interval
Preserving data:
ISaveFromTheLastResponseNodeAs Saves from last response body JSON node under given cacheKey key
ISaveAs Saves into cache arbitrary passed value
Debugging:
IPrintLastResponseBody Prints last response from request
IStartDebugMode Starts debugging mode
IStopDebugMode Stops debugging mode
Flow control:
IWait Stops test execution for provided amount of time
Assertions:
TheResponseShouldHaveHeader Checks whether last HTTP(s) response has given header
TheResponseShouldHaveHeaderOfValue Checks whether last HTTP(s) response has given header with provided value
TheResponseStatusCodeShouldBe Checks last HTTP(s) response status code
TheResponseBodyShouldHaveType Checks whether last HTTP(s) response body has given data format
TheResponseShouldHaveNode Checks whether last response body contains given key
TheNodeShouldBeOfValue Compares json node value from expression to expected by user
TheNodeShouldBe Checks whether node from last HTTP(s) response body is of provided type
TheNodeShouldNotBe Checks whether node from last response body is not of provided type
TheResponseShouldHaveNodes Checks whether last HTTP(s) response body JSON has given nodes
TheNodeShouldMatchRegExp Checks whether last HTTP(s) response body JSON node matches regExp
TheNodeShouldBeSliceOfLength checks whether given key is slice and has given length
IValidateLastResponseBodyWithSchemaReference Validates last HTTP(s) response body against provided in reference JSON schema
IValidateLastResponseBodyWithSchemaString Validates last HTTP(s) response body against provided JSON schema
IValidateJSONNodeWithSchemaString Validates last HTTP(s) response body JSON node against provided JSON schema
IValidateJSONNodeWithSchemaReference Validates last HTTP(s) response body JSON node against provided in reference JSON schema
TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualTo Asserts that last HTTP(s) request-response time is <= than expected
TheResponseShouldHaveCookie Checks whether last HTTP(s) response has given cookie
TheResponseShouldHaveCookieOfValue Checks whether last HTTP(s) response has given cookie of given value

Documentation

Overview

Package gdutils provides State struct with methods that may be used for behavioral testing of HTTP API.

State may be initialized by two ways:

First, returns *State with default services:

func NewDefaultState(isDebug bool, jsonSchemaDir string) *State

Second, more customisable returns *State with provided services:

func NewState(cli *http.Client, c cache.Cache, jv SchemaValidators, p PathFinders, d Formatters, isDebug bool) *State

No matter which way you choose, you can inject your custom services afterwards with one of available setters:

func (s *State) SetDebugger(d debugger.Debugger)
func (s *State) SetCache(c cache.Cache)
func (s *State) SetRequestDoer(r httpctx.RequestDoer)
func (s *State) SetTemplateEngine(t template.Engine)
func (s *State) SetSchemaStringValidator(j validator.SchemaValidator)
func (s *State) SetSchemaReferenceValidator(j validator.SchemaValidator)
func (s *State) SetJSONPathFinder(r pathfinder.PathFinder)
func (s *State) SetJSONFormatter(jf formatter.Formatter)
func (s *State) SetXMLPathFinder(r pathfinder.PathFinder)
func (s *State) SetYAMLPathFinder(r pathfinder.PathFinder)
func (s *State) SetYAMLFormatter(yd formatter.Formatter)
func (s *State) SetXMLFormatter(xf formatter.Formatter)

Those services will be used in utility methods. For example, if you want to use your own debugger, create your own struct, implement debugger.Debugger interface on it, and then inject it with "func (s *State) SetDebugger(d debugger.Debugger)" method.

Testing HTTP API usually consist the following aspects:

* Data generation:

	func (s *State) IGenerateARandomIntInTheRangeToAndSaveItAs(from, to int, cacheKey string) error
	func (s *State) IGenerateARandomFloatInTheRangeToAndSaveItAs(from, to int, cacheKey string) error
 func (s *State) IGenerateARandomRunesInTheRangeToAndSaveItAs(charset string) func(from, to int, cacheKey string) error
	func (s *State) IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAs(charset string, wordMinLength, wordMaxLength int) func(from, to int, cacheKey string) error
	func (s *State) IGetTimeAndTravelByAndSaveItAs(t time.Time, timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error
	func (s *State) IGenerateCurrentTimeAndTravelByAndSaveItAs(timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

* Sending HTTP(s) requests:

func (s *State) ISendRequestToWithBodyAndHeaders(method, urlTemplate string, bodyTemplate string) error

or

func (s *State) IPrepareNewRequestToAndSaveItAs(method, urlTemplate, cacheKey string) error
func (s *State) ISetFollowingHeadersForPreparedRequest(cacheKey string, headersTemplate string) error
func (s *State) ISetFollowingFormForPreparedRequest(cacheKey, formTemplate string) error
func (s *State) ISetFollowingCookiesForPreparedRequest(cacheKey, cookiesTemplate string) error
func (s *State) ISetFollowingBodyForPreparedRequest(cacheKey string, bodyTemplate string) error
func (s *State) ISendRequest(cacheKey string) error

* Assertions:

	func (s *State) TheResponseStatusCodeShouldBe(code int) error
	func (s *State) TheResponseBodyShouldHaveFormat(dataFormat format.DataFormat) error
	func (s *State) TheResponseShouldHaveCookie(name string) error
	func (s *State) TheResponseShouldHaveCookieOfValue(name, valueTemplate string) error
	func (s *State) TheResponseShouldHaveNode(dataFormat format.DataFormat, expr string) error
	func (s *State) TheNodeShouldNotBe(df format.DataFormat, expr string, goType string) error
	func (s *State) TheNodeShouldBe(df format.DataFormat, expr string, goType string) error
	func (s *State) TheNodeShouldMatchRegExp(dataFormat format.DataFormat, expr, regExpTemplate string) error
	func (s *State) TheResponseShouldHaveNodes(dataFormat format.DataFormat, expressions string) error
	func (s *State) TheNodeShouldBeSliceOfLength(dataFormat format.DataFormat, expr string, length int) error
	func (s *State) TheNodeShouldBeOfValue(dataFormat format.DataFormat, expr, dataType, dataValue string) error
	func (s *State) TheResponseShouldHaveHeader(name string) error
	func (s *State) TheResponseShouldHaveHeaderOfValue(name, value string) error
 func (s *State) IValidateLastResponseBodyWithSchemaReference(reference string) error
	func (s *State) IValidateLastResponseBodyWithSchemaString(schema string) error
	func (s *State) IValidateNodeWithSchemaString(dataFormat format.DataFormat, expr, schema string) error
	func (s *State) IValidateNodeWithSchemaReference(dataFormat format.DataFormat, expr, reference string) error
	func (s *State) TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualTo(timeInterval time.Duration) error

* Preserving JSON nodes:

	func (s *State) ISaveFromTheLastResponseNodeAs(dataFormat format.DataFormat, expr, cacheKey string) error
 func (s *State) ISaveAs(value, cacheKey string) error

* Temporary stopping scenario execution:

func (s *State) IWait(timeInterval time.Duration) error

* Debugging:

func (s *State) IPrintLastResponseBody() error
func (s *State) IStartDebugMode() error
func (s *State) IStopDebugMode() error

Index

Constants

This section is empty.

Variables

View Source
var ErrGdutils = errors.New("gdutils")

ErrGdutils is general package error and can be tested against

View Source
var ErrHTTPReqRes = fmt.Errorf("%w: something wrong with HTTP(s) request/response", ErrGdutils)

ErrHTTPReqRes tells that there is problem with last HTTP(s) request/response

View Source
var ErrJson = fmt.Errorf("%w: something wrong with JSON", ErrGdutils)

ErrJson tells that there is problem with JSON

View Source
var ErrPreservedData = errors.New("preserved data error")

ErrPreservedData tells indices that there is some kind of error with scenario preserved data.

Functions

This section is empty.

Types

type BodyHeaders added in v0.7.4

type BodyHeaders struct {

	// Body should contain HTTP(s) request body
	Body interface{}

	// Headers should contain HTTP(s) request headers
	Headers map[string]string
}

BodyHeaders is entity that holds information about request body and request headers.

type Formatters added in v0.12.0

type Formatters struct {
	// JSON is entity that has ability to serialize and deserialize JSON bytes.
	JSON formatter.Formatter

	// YAML is entity that has ability to serialize and deserialize YAML bytes.
	YAML formatter.Formatter

	// XML is entity that has ability to serialize and deserialize XML bytes.
	XML formatter.Formatter
}

Formatters is container for entities that know how to serialize and deserialize data.

type PathFinders added in v0.12.0

type PathFinders struct {
	// JSON is entity that has ability to obtain data from bytes in JSON format.
	JSON pathfinder.PathFinder

	// YAML is entity that has ability to obtain data from bytes in YAML format.
	YAML pathfinder.PathFinder

	// XML is entity that has ability to obtain data from bytes in XML format.
	XML pathfinder.PathFinder
}

PathFinders is container for different data types pathfinders.

type SchemaValidators added in v0.12.0

type SchemaValidators struct {
	// StringValidator represents entity that has ability to validate document against string of containing schema.
	StringValidator validator.SchemaValidator

	// ReferenceValidator represents entity that has ability to validate document against string with reference
	// to schema, which may be URL or relative/full OS path for example.
	ReferenceValidator validator.SchemaValidator
}

SchemaValidators is container for JSON schema validators.

type State

type State struct {
	// Debugger represents scenario debugger.
	Debugger debugger.Debugger

	// Cache is storage for scenario data.
	Cache cache.Cache

	// RequestDoer is service that has ability to send HTTP(s) requests
	RequestDoer httpctx.RequestDoer

	// TemplateEngine is entity that has ability to work with template values.
	TemplateEngine template.Engine

	// SchemaValidators holds validators available to validate JSON Schemas.
	SchemaValidators SchemaValidators

	// PathFinders are entities that has ability to obtain data from different data formats.
	PathFinders PathFinders

	// Formatters are entities that has ability to deserialize data from one of available formats.
	Formatters Formatters
	// contains filtered or unexported fields
}

State struct represents data shared across one scenario.

func NewDefaultState

func NewDefaultState(isDebug bool, jsonSchemaDir string) *State

NewDefaultState returns *State with default services. jsonSchemaDir may be empty string or valid full path to directory with JSON schemas.

func NewState

func NewState(cli *http.Client, c cache.Cache, jv SchemaValidators, p PathFinders, f Formatters, isDebug bool) *State

NewState returns *State

func (*State) GetLastResponse

func (s *State) GetLastResponse() (*http.Response, error)

GetLastResponse returns last HTTP(s) response.

func (*State) GetLastResponseBody

func (s *State) GetLastResponseBody() ([]byte, error)

GetLastResponseBody returns last HTTP(s) response body. internally method creates new NoPCloser on last response so this method is safe to reuse many times

func (*State) GetPreparedRequest added in v0.11.0

func (s *State) GetPreparedRequest(cacheKey string) (*http.Request, error)

GetPreparedRequest returns prepared request from cache or error if failed

func (*State) IGenerateARandomFloatInTheRangeToAndSaveItAs

func (s *State) IGenerateARandomFloatInTheRangeToAndSaveItAs(from, to int, cacheKey string) error

IGenerateARandomFloatInTheRangeToAndSaveItAs generates random float from provided range and preserve it under given cacheKey key.

func (*State) IGenerateARandomIntInTheRangeToAndSaveItAs

func (s *State) IGenerateARandomIntInTheRangeToAndSaveItAs(from, to int, cacheKey string) error

IGenerateARandomIntInTheRangeToAndSaveItAs generates random integer from provided range and preserve it under given cacheKey key.

func (*State) IGenerateARandomRunesInTheRangeToAndSaveItAs added in v0.9.0

func (s *State) IGenerateARandomRunesInTheRangeToAndSaveItAs(charset string) func(from, to int, cacheKey string) error

IGenerateARandomRunesInTheRangeToAndSaveItAs creates random runes generator func using provided charset return func creates runes from provided range and preserve it under given cacheKey

func (*State) IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAs added in v0.9.1

func (s *State) IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAs(charset string, wordMinLength, wordMaxLength int) func(from, to int, cacheKey string) error

IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAs creates generator func for creating random sentences each sentence has length from - to as provided in params and is saved in provided cacheKey

func (*State) IGenerateCurrentTimeAndTravelByAndSaveItAs added in v0.10.0

func (s *State) IGenerateCurrentTimeAndTravelByAndSaveItAs(timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

IGenerateCurrentTimeAndTravelByAndSaveItAs creates current time object, move timeDuration in time and save it in cache under given cacheKey.

func (*State) IGetTimeAndTravelByAndSaveItAs added in v0.10.0

func (s *State) IGetTimeAndTravelByAndSaveItAs(t time.Time, timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

IGetTimeAndTravelByAndSaveItAs accepts time object, move timeDuration in time and save it in cache under given cacheKey.

func (*State) IPrepareNewRequestToAndSaveItAs added in v0.7.0

func (s *State) IPrepareNewRequestToAndSaveItAs(method, urlTemplate, cacheKey string) error

IPrepareNewRequestToAndSaveItAs prepares new request and saves it in cache under cacheKey

func (*State) IPrintLastResponseBody

func (s *State) IPrintLastResponseBody() error

IPrintLastResponseBody prints last response from request.

func (*State) ISaveAs added in v0.9.4

func (s *State) ISaveAs(value, cacheKey string) error

ISaveAs saves into cache arbitrary passed value.

func (*State) ISaveFromTheLastResponseNodeAs added in v0.12.0

func (s *State) ISaveFromTheLastResponseNodeAs(dataFormat format.DataFormat, expr, cacheKey string) error

ISaveFromTheLastResponseNodeAs saves from last response body node under given cacheKey key. expr should be valid according to injected PathResolver of given data type

func (*State) ISendRequest added in v0.7.0

func (s *State) ISendRequest(cacheKey string) error

ISendRequest sends previously prepared HTTP(s) request.

func (*State) ISendRequestToWithBodyAndHeaders

func (s *State) ISendRequestToWithBodyAndHeaders(method, urlTemplate string, bodyTemplate string) error
	ISendRequestToWithFormatBodyAndHeaders sends HTTP(s) requests with provided body and headers.

	Argument "method" indices HTTP request method for example: "POST", "GET" etc.
 	Argument "urlTemplate" should be full valid URL. May include template values.
	Argument "bodyTemplate" should contain data (may include template values)
	in JSON or YAML format with keys "body" and "headers".

func (*State) ISetFollowingBodyForPreparedRequest added in v0.7.0

func (s *State) ISetFollowingBodyForPreparedRequest(cacheKey, bodyTemplate string) error

ISetFollowingBodyForPreparedRequest sets body for previously prepared request bodyTemplate may be in any format and accepts template values

func (*State) ISetFollowingCookiesForPreparedRequest added in v0.11.1

func (s *State) ISetFollowingCookiesForPreparedRequest(cacheKey, cookiesTemplate string) error

ISetFollowingCookiesForPreparedRequest sets cookies for previously prepared request. cookiesTemplate should be YAML or JSON deserializable on []http.Cookie.

func (*State) ISetFollowingFormForPreparedRequest added in v0.12.3

func (s *State) ISetFollowingFormForPreparedRequest(cacheKey, formTemplate string) error

ISetFollowingFormForPreparedRequest sets form for previously prepared request. Internally method sets proper Content-Type: multipart/form-data header. formTemplate should be YAML or JSON deserializable on map[string]string.

func (*State) ISetFollowingHeadersForPreparedRequest added in v0.7.0

func (s *State) ISetFollowingHeadersForPreparedRequest(cacheKey, headersTemplate string) error

ISetFollowingHeadersForPreparedRequest sets provided headers for previously prepared request. incoming data should be in JSON or YAML format

func (*State) IStartDebugMode

func (s *State) IStartDebugMode() error

IStartDebugMode starts debugging mode

func (*State) IStopDebugMode

func (s *State) IStopDebugMode() error

IStopDebugMode stops debugging mode

func (*State) IValidateLastResponseBodyWithSchemaReference added in v0.9.1

func (s *State) IValidateLastResponseBodyWithSchemaReference(referenceTemplate string) error

IValidateLastResponseBodyWithSchemaReference validates last response body against schema as provided in referenceTemplate. referenceTemplate may be: URL or full/relative path

func (*State) IValidateLastResponseBodyWithSchemaString added in v0.9.1

func (s *State) IValidateLastResponseBodyWithSchemaString(schema string) error

IValidateLastResponseBodyWithSchemaString validates last response body against schema.

func (*State) IValidateNodeWithSchemaReference added in v0.12.0

func (s *State) IValidateNodeWithSchemaReference(dataFormat format.DataFormat, expr, referenceTemplate string) error

IValidateNodeWithSchemaReference validates last response body node against schema as provided in referenceTemplate

func (*State) IValidateNodeWithSchemaString added in v0.12.0

func (s *State) IValidateNodeWithSchemaString(dataFormat format.DataFormat, expr, schema string) error

IValidateNodeWithSchemaString validates last response body JSON node against schema

func (*State) IWait

func (s *State) IWait(timeInterval time.Duration) error

IWait waits for given timeInterval amount of time

func (*State) ResetState

func (s *State) ResetState(isDebug bool)

ResetState resets State struct instance to default values.

func (*State) SetCache added in v0.9.3

func (s *State) SetCache(c cache.Cache)

SetCache sets new Cache for State.

func (*State) SetDebugger added in v0.9.3

func (s *State) SetDebugger(d debugger.Debugger)

SetDebugger sets new debugger for State.

func (*State) SetJSONFormatter added in v0.12.0

func (s *State) SetJSONFormatter(jf formatter.Formatter)

SetJSONFormatter sets new JSON formatter for State.

func (*State) SetJSONPathFinder added in v0.12.0

func (s *State) SetJSONPathFinder(r pathfinder.PathFinder)

SetJSONPathFinder sets new JSON pathfinder for State.

func (*State) SetRequestDoer added in v0.11.0

func (s *State) SetRequestDoer(r httpctx.RequestDoer)

SetRequestDoer sets new RequestDoer for State.

func (*State) SetSchemaReferenceValidator added in v0.12.0

func (s *State) SetSchemaReferenceValidator(j validator.SchemaValidator)

SetSchemaReferenceValidator sets new schema ReferenceValidator for State.

func (*State) SetSchemaStringValidator added in v0.12.0

func (s *State) SetSchemaStringValidator(j validator.SchemaValidator)

SetSchemaStringValidator sets new schema StringValidator for State.

func (*State) SetTemplateEngine added in v0.9.3

func (s *State) SetTemplateEngine(t template.Engine)

SetTemplateEngine sets new template Engine for State.

func (*State) SetXMLFormatter added in v0.13.0

func (s *State) SetXMLFormatter(xf formatter.Formatter)

SetXMLFormatter sets new XML formatter for State.

func (*State) SetXMLPathFinder added in v0.13.0

func (s *State) SetXMLPathFinder(r pathfinder.PathFinder)

SetXMLPathFinder sets new XML pathfinder for State.

func (*State) SetYAMLFormatter added in v0.12.0

func (s *State) SetYAMLFormatter(yd formatter.Formatter)

SetYAMLFormatter sets new YAML formatter for State.

func (*State) SetYAMLPathFinder added in v0.12.0

func (s *State) SetYAMLPathFinder(r pathfinder.PathFinder)

SetYAMLPathFinder sets new YAML pathfinder for State.

func (*State) TheNodeShouldBe added in v0.12.0

func (s *State) TheNodeShouldBe(dataFormat format.DataFormat, expr string, goType string) error

TheNodeShouldBe checks whether node from last response body is of provided type goType may be one of: nil, string, int, float, bool, map, slice expr should be valid according to injected PathResolver

func (*State) TheNodeShouldBeOfValue added in v0.12.0

func (s *State) TheNodeShouldBeOfValue(dataFormat format.DataFormat, expr, dataType, dataValue string) error

TheNodeShouldBeOfValue compares json node value from expression to expected by user dataValue of given by user dataType Available data types are listed in switch section in each case directive. expr should be valid according to injected PathFinder for provided dataFormat.

func (*State) TheNodeShouldBeSliceOfLength added in v0.12.0

func (s *State) TheNodeShouldBeSliceOfLength(dataFormat format.DataFormat, expr string, length int) error

TheNodeShouldBeSliceOfLength checks whether given key is slice and has given length expr should be valid according to injected PathFinder for provided dataFormat

func (*State) TheNodeShouldMatchRegExp added in v0.12.0

func (s *State) TheNodeShouldMatchRegExp(dataFormat format.DataFormat, expr, regExpTemplate string) error

TheNodeShouldMatchRegExp checks whether last response body node matches provided regExp.

func (*State) TheNodeShouldNotBe added in v0.12.0

func (s *State) TheNodeShouldNotBe(dataFormat format.DataFormat, expr string, goType string) error

TheNodeShouldNotBe checks whether node from last response body is not of provided type. goType may be one of: nil, string, int, float, bool, map, slice, expr should be valid according to injected PathFinder for given data format.

func (*State) TheResponseBodyShouldHaveFormat added in v0.10.0

func (s *State) TheResponseBodyShouldHaveFormat(dataFormat format.DataFormat) error

TheResponseBodyShouldHaveFormat checks whether last response body has given data format. Available data formats are listed in format package.

func (*State) TheResponseShouldHaveCookie added in v0.11.1

func (s *State) TheResponseShouldHaveCookie(name string) error

TheResponseShouldHaveCookie checks whether last HTTP(s) response has cookie of given name.

func (*State) TheResponseShouldHaveCookieOfValue added in v0.11.1

func (s *State) TheResponseShouldHaveCookieOfValue(name, valueTemplate string) error

TheResponseShouldHaveCookieOfValue checks whether last HTTP(s) response has cookie of given name and value.

func (*State) TheResponseShouldHaveHeader

func (s *State) TheResponseShouldHaveHeader(name string) error

TheResponseShouldHaveHeader checks whether last HTTP response has given header.

func (*State) TheResponseShouldHaveHeaderOfValue

func (s *State) TheResponseShouldHaveHeaderOfValue(name, valueTemplate string) error

TheResponseShouldHaveHeaderOfValue checks whether last HTTP response has given header with provided valueTemplate.

func (*State) TheResponseShouldHaveNode added in v0.12.0

func (s *State) TheResponseShouldHaveNode(dataFormat format.DataFormat, expr string) error

TheResponseShouldHaveNode checks whether last response body contains given node. expr should be valid according to injected PathFinder for given data format

func (*State) TheResponseShouldHaveNodes added in v0.12.0

func (s *State) TheResponseShouldHaveNodes(dataFormat format.DataFormat, expressions string) error

TheResponseShouldHaveNodes checks whether last request body has keys defined in string separated by comma nodeExprs should be valid according to injected PathFinder expressions separated by comma (,)

func (*State) TheResponseStatusCodeShouldBe

func (s *State) TheResponseStatusCodeShouldBe(code int) error

TheResponseStatusCodeShouldBe compare last response status code with given in argument.

func (*State) TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualTo added in v0.9.4

func (s *State) TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualTo(timeInterval time.Duration) error

TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualTo asserts that last HTTP request-response time is <= than expected timeInterval. timeInterval should be string acceptable by time.ParseDuration func

Directories

Path Synopsis
pkg
Package pkg holds packages used for steps.
Package pkg holds packages used for steps.
cache
Package cache holds definition of Cache used for storing and retrieving data.
Package cache holds definition of Cache used for storing and retrieving data.
debugger
Package debugger holds definition of Debugger.
Package debugger holds definition of Debugger.
formatter
Package formatter holds utilities for working with different data formats.
Package formatter holds utilities for working with different data formats.
httpcache
Package httpcache connects package httpctx and cache
Package httpcache connects package httpctx and cache
httpctx
Package httpctx holds utilities for working with HTTP protocol.
Package httpctx holds utilities for working with HTTP protocol.
mathutils
Package mathutils holds utilities related with mathematics.
Package mathutils holds utilities related with mathematics.
pathfinder
Package pathfinder holds utilities for working with JSON path.
Package pathfinder holds utilities for working with JSON path.
reflectutils
Package reflectutils holds utility methods related with reflect package.
Package reflectutils holds utility methods related with reflect package.
stringutils
Package stringutils holds utility methods for working with strings.
Package stringutils holds utility methods for working with strings.
template
Package template holds utilities for working with templates.
Package template holds utilities for working with templates.
validator
Package validator holds utilities for validating data.
Package validator holds utilities for validating data.

Jump to

Keyboard shortcuts

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