gdutils

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 35 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:
RequestSendWithBodyAndHeaders Sends HTTP(s) request with provided body and headers.
RequestPrepare Prepare HTTP(s) request
RequestSetHeaders Sets provided headers for previously prepared request
RequestSetForm Sets provided form for previously prepared request
RequestSetCookies Sets provided cookies for previously prepared request
RequestSetBody Sets body for previously prepared request
RequestSend Sends previously prepared HTTP(s) request
Random data generation:
GenerateRandomInt Generates random integer from provided range and save it under provided cache key
GenerateFloat64 Generates random float from provided range and save it under provided cache key
GeneratorRandomRunes Creates generator for random strings from provided charset in provided range
GeneratorRandomSentence Creates generator for random sentence from provided charset in provided range
GetTimeAndTravel Accepts time object and move in time by given time interval
GenerateTimeAndTravel Creates current time object and move in time by given time interval
Preserving data:
SaveNode Saves from last response body JSON node under given cacheKey key
SaveHeader Saves into cache given header value
Save Saves into cache arbitrary passed value
Debugging:
DebugPrintResponseBody Prints last response from request
DebugStart Starts debugging mode
DebugStop Stops debugging mode
Flow control:
Wait Stops test execution for provided amount of time
Assertions:
AssertResponseHeaderExists Checks whether last HTTP(s) response has given header
AssertResponseHeaderNotExists Checks whether last HTTP(s) response doesn't have given header
AssertResponseHeaderValueIs Checks whether last HTTP(s) response has given header with provided value
AssertStatusCodeIs Checks last HTTP(s) response status code
AssertStatusCodeIsNot Checks if last HTTP(s) response status code is not of provided value
AssertResponseFormatIs Checks whether last HTTP(s) response body has given data format
AssertResponseFormatIsNot Checks whether last HTTP(s) response body doesn't have given data format
AssertNodeExists Checks whether last response body contains given key
AssertNodeNotExists Checks whether last response body doesn't contain given key
AssertNodesExist Checks whether last HTTP(s) response body JSON has given nodes
AssertNodeIsTypeAndValue Compares json node value from expression to expected by user
AssertNodeIsType Checks whether node from last HTTP(s) response body is of provided type
AssertNodeIsNotType Checks whether node from last HTTP(s) response body is not of provided type
AssertNodeIsNotType Checks whether node from last response body is not of provided type
AssertNodeMatchesRegExp Checks whether last HTTP(s) response body JSON node matches regExp
AssertNodeNotMatchesRegExp Checks whether last HTTP(s) response body JSON node doesn't match regExp
AssertNodeSliceLengthIs checks whether given key is slice and has given length
AssertNodeSliceLengthIsNot checks whether given key is slice and doesn't have given length
AssertResponseMatchesSchemaByReference Validates last HTTP(s) response body against provided in reference JSON schema
AssertResponseMatchesSchemaByString Validates last HTTP(s) response body against provided JSON schema
AssertNodeMatchesSchemaByString Validates last HTTP(s) response body JSON node against provided JSON schema
AssertNodeMatchesSchemaByReference Validates last HTTP(s) response body JSON node against provided in reference JSON schema
AssertTimeBetweenRequestAndResponseIs Asserts that last HTTP(s) request-response time is <= than expected
AssertResponseCookieExists Checks whether last HTTP(s) response has given cookie
AssertResponseCookieNotExists Checks whether last HTTP(s) response doesn't have given cookie
AssertResponseCookieValueIs Checks whether last HTTP(s) response has given cookie of given value

Documentation

Overview

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

APIContext may be initialized by two ways:

First, returns *APIContext with default services:

func NewDefaultAPIContext(isDebug bool, jsonSchemaDir string) *APIContext

Second, more customisable returns *APIContext with provided services:

func NewAPIContext(cli *http.Client, c cache.Cache, jv SchemaValidators, p PathFinders, f Formatters, d debugger.Debugger) *APIContext

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

func (apiCtx *APIContext) SetDebugger(d debugger.Debugger)
func (apiCtx *APIContext) SetCache(c cache.Cache)
func (apiCtx *APIContext) SetRequestDoer(r httpctx.RequestDoer)
func (apiCtx *APIContext) SetTemplateEngine(t template.Engine)
func (apiCtx *APIContext) SetSchemaStringValidator(j validator.SchemaValidator)
func (apiCtx *APIContext) SetSchemaReferenceValidator(j validator.SchemaValidator)
func (apiCtx *APIContext) SetJSONPathFinder(r pathfinder.PathFinder)
func (apiCtx *APIContext) SetJSONFormatter(jf formatter.Formatter)
func (apiCtx *APIContext) SetXMLPathFinder(r pathfinder.PathFinder)
func (apiCtx *APIContext) SetYAMLPathFinder(r pathfinder.PathFinder)
func (apiCtx *APIContext) SetYAMLFormatter(yd formatter.Formatter)
func (apiCtx *APIContext) 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 (apiCtx *APIContext) SetDebugger(d debugger.Debugger)" method.

Testing HTTP API usually consist the following aspects:

* Data generation:

	func (apiCtx *APIContext) GenerateRandomInt(from, to int, cacheKey string) error
	func (apiCtx *APIContext) GenerateFloat64(from, to float64, cacheKey string) error
 func (apiCtx *APIContext) GeneratorRandomRunes(charset string) func(from, to int, cacheKey string) error
	func (apiCtx *APIContext) GeneratorRandomSentence(charset string, wordMinLength, wordMaxLength int) func(from, to int, cacheKey string) error
	func (apiCtx *APIContext) GetTimeAndTravel(t time.Time, timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error
	func (apiCtx *APIContext) GenerateTimeAndTravel(timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

* Sending HTTP(s) requests:

func (apiCtx *APIContext) RequestSendWithBodyAndHeaders(method, urlTemplate string, bodyTemplate string) error

or

func (apiCtx *APIContext) RequestPrepare(method, urlTemplate, cacheKey string) error
func (apiCtx *APIContext) RequestSetHeaders(cacheKey string, headersTemplate string) error
func (apiCtx *APIContext) RequestSetForm(cacheKey, formTemplate string) error
func (apiCtx *APIContext) RequestSetCookies(cacheKey, cookiesTemplate string) error
func (apiCtx *APIContext) RequestSetBody(cacheKey string, bodyTemplate string) error
func (apiCtx *APIContext) RequestSend(cacheKey string) error

* Assertions:

	func (apiCtx *APIContext) AssertStatusCodeIs(code int) error
	func (apiCtx *APIContext) AssertStatusCodeIsNot(code int) error
	func (apiCtx *APIContext) AssertResponseFormatIs(dataFormat format.DataFormat) error
	func (apiCtx *APIContext) AssertResponseFormatIsNot(dataFormat format.DataFormat) error
	func (apiCtx *APIContext) AssertResponseCookieExists(name string) error
	func (apiCtx *APIContext) AssertResponseCookieNotExists(name string) error
	func (apiCtx *APIContext) AssertResponseCookieValueIs(name, valueTemplate string) error
	func (apiCtx *APIContext) AssertNodesExist(dataFormat format.DataFormat, expressionsTemplates string) error
	func (apiCtx *APIContext) AssertNodeExists(dataFormat format.DataFormat, exprTemplate string) error
	func (apiCtx *APIContext) AssertNodeNotExists(dataFormat format.DataFormat, exprTemplate string) error
	func (apiCtx *APIContext) AssertNodeIsType(df format.DataFormat, exprTemplate string, goType string) error
	func (apiCtx *APIContext) AssertNodeIsNotType(df format.DataFormat, exprTemplate string, goType string) error
	func (apiCtx *APIContext) AssertNodeMatchesRegExp(dataFormat format.DataFormat, exprTemplate, regExpTemplate string) error
	func (apiCtx *APIContext) AssertNodeNotMatchesRegExp(dataFormat format.DataFormat, exprTemplate, regExpTemplate string) error
	func (apiCtx *APIContext) AssertNodeSliceLengthIs(dataFormat format.DataFormat, exprTemplate string, length int) error
	func (apiCtx *APIContext) AssertNodeSliceLengthIsNot(dataFormat format.DataFormat, exprTemplate string, length int) error
	func (apiCtx *APIContext) AssertNodeIsTypeAndValue(dataFormat format.DataFormat, exprTemplate, dataType, dataValue string) error
	func (apiCtx *APIContext) AssertResponseHeaderExists(name string) error
	func (apiCtx *APIContext) AssertResponseHeaderNotExists(name string) error
	func (apiCtx *APIContext) AssertResponseHeaderValueIs(name, value string) error
 func (apiCtx *APIContext) AssertResponseMatchesSchemaByReference(referenceTemplate string) error
	func (apiCtx *APIContext) AssertResponseMatchesSchemaByString(schemaTemplate string) error
	func (apiCtx *APIContext) AssertNodeMatchesSchemaByString(dataFormat format.DataFormat, exprTemplate, schemaTemplate string) error
	func (apiCtx *APIContext) AssertNodeMatchesSchemaByReference(dataFormat format.DataFormat, exprTemplate, referenceTemplate string) error
	func (apiCtx *APIContext) AssertTimeBetweenRequestAndResponseIs(timeInterval time.Duration) error

* Preserving nodes:

	func (apiCtx *APIContext) SaveNode(dataFormat format.DataFormat, exprTemplate, cacheKey string) error
	func (apiCtx *APIContext) SaveHeader(name, cacheKey string) error
 func (apiCtx *APIContext) Save(valueTemplate, cacheKey string) error

* Flow control:

func (apiCtx *APIContext) Wait(timeInterval time.Duration) error

* Debugging:

func (apiCtx *APIContext) DebugPrintResponseBody() error
func (apiCtx *APIContext) DebugStart() error
func (apiCtx *APIContext) DebugStop() error

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIContext added in v0.14.1

type APIContext struct {
	// Debugger represents debugger.
	Debugger debugger.Debugger

	// Cache is storage for 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 data against 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 format data in particular format.
	Formatters Formatters
	// contains filtered or unexported fields
}

APIContext holds utility services for working with HTTP(s) API.

func NewAPIContext added in v0.14.1

NewAPIContext returns *APIContext

func NewDefaultAPIContext added in v0.14.1

func NewDefaultAPIContext(isDebug bool, jsonSchemaDir string) *APIContext

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

func (*APIContext) AssertNodeExists added in v1.0.0

func (apiCtx *APIContext) AssertNodeExists(dataFormat format.DataFormat, exprTemplate string) error

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

func (*APIContext) AssertNodeIsNotType added in v1.0.0

func (apiCtx *APIContext) AssertNodeIsNotType(dataFormat format.DataFormat, exprTemplate string, goType string) error

AssertNodeIsNotType 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 (*APIContext) AssertNodeIsType added in v1.0.0

func (apiCtx *APIContext) AssertNodeIsType(dataFormat format.DataFormat, exprTemplate string, goType string) error

AssertNodeIsType 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 (*APIContext) AssertNodeIsTypeAndValue added in v1.0.0

func (apiCtx *APIContext) AssertNodeIsTypeAndValue(dataFormat format.DataFormat, exprTemplate, dataType, dataValue string) error

AssertNodeIsTypeAndValue 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 (*APIContext) AssertNodeMatchesRegExp added in v1.0.0

func (apiCtx *APIContext) AssertNodeMatchesRegExp(dataFormat format.DataFormat, exprTemplate, regExpTemplate string) error

AssertNodeMatchesRegExp checks whether last response body node matches provided regExp.

func (*APIContext) AssertNodeMatchesSchemaByReference added in v1.0.0

func (apiCtx *APIContext) AssertNodeMatchesSchemaByReference(dataFormat format.DataFormat, exprTemplate, referenceTemplate string) error

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

func (*APIContext) AssertNodeMatchesSchemaByString added in v1.0.0

func (apiCtx *APIContext) AssertNodeMatchesSchemaByString(dataFormat format.DataFormat, exprTemplate, schemaTemplate string) error

AssertNodeMatchesSchemaByString validates last response body JSON node against schema

func (*APIContext) AssertNodeNotExists added in v1.0.0

func (apiCtx *APIContext) AssertNodeNotExists(dataFormat format.DataFormat, exprTemplate string) error

AssertNodeNotExists checks whether last response body does not contain given node. expr should be valid according to injected PathFinder for given data format

func (*APIContext) AssertNodeNotMatchesRegExp added in v1.0.0

func (apiCtx *APIContext) AssertNodeNotMatchesRegExp(dataFormat format.DataFormat, exprTemplate, regExpTemplate string) error

AssertNodeNotMatchesRegExp checks whether last response body node does not match provided regExp.

func (*APIContext) AssertNodeSliceLengthIs added in v1.0.0

func (apiCtx *APIContext) AssertNodeSliceLengthIs(dataFormat format.DataFormat, exprTemplate string, length int) error

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

func (*APIContext) AssertNodeSliceLengthIsNot added in v1.0.0

func (apiCtx *APIContext) AssertNodeSliceLengthIsNot(dataFormat format.DataFormat, exprTemplate string, length int) error

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

func (*APIContext) AssertNodesExist added in v1.0.0

func (apiCtx *APIContext) AssertNodesExist(dataFormat format.DataFormat, expressionsTemplate string) error

AssertNodesExist 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 (*APIContext) AssertResponseCookieExists added in v1.0.0

func (apiCtx *APIContext) AssertResponseCookieExists(name string) error

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

func (*APIContext) AssertResponseCookieNotExists added in v1.0.0

func (apiCtx *APIContext) AssertResponseCookieNotExists(name string) error

AssertResponseCookieNotExists checks whether last HTTP(s) response does not have cookie of given name.

func (*APIContext) AssertResponseCookieValueIs added in v1.0.0

func (apiCtx *APIContext) AssertResponseCookieValueIs(name, valueTemplate string) error

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

func (*APIContext) AssertResponseFormatIs added in v1.0.0

func (apiCtx *APIContext) AssertResponseFormatIs(dataFormat format.DataFormat) error

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

func (*APIContext) AssertResponseFormatIsNot added in v1.0.0

func (apiCtx *APIContext) AssertResponseFormatIsNot(dataFormat format.DataFormat) error

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

func (*APIContext) AssertResponseHeaderExists added in v1.0.0

func (apiCtx *APIContext) AssertResponseHeaderExists(name string) error

AssertResponseHeaderExists checks whether last HTTP response has given header.

func (*APIContext) AssertResponseHeaderNotExists added in v1.0.0

func (apiCtx *APIContext) AssertResponseHeaderNotExists(name string) error

AssertResponseHeaderNotExists checks whether last HTTP response does not have given header.

func (*APIContext) AssertResponseHeaderValueIs added in v1.0.0

func (apiCtx *APIContext) AssertResponseHeaderValueIs(name, valueTemplate string) error

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

func (*APIContext) AssertResponseMatchesSchemaByReference added in v1.0.0

func (apiCtx *APIContext) AssertResponseMatchesSchemaByReference(referenceTemplate string) error

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

func (*APIContext) AssertResponseMatchesSchemaByString added in v1.0.0

func (apiCtx *APIContext) AssertResponseMatchesSchemaByString(schema string) error

AssertResponseMatchesSchemaByString validates last response body against schema.

func (*APIContext) AssertStatusCodeIs added in v1.0.0

func (apiCtx *APIContext) AssertStatusCodeIs(code int) error

AssertStatusCodeIs compare last response status code with given in argument.

func (*APIContext) AssertStatusCodeIsNot added in v1.0.0

func (apiCtx *APIContext) AssertStatusCodeIsNot(code int) error

AssertStatusCodeIsNot asserts that last response status code is not provided.

func (*APIContext) AssertTimeBetweenRequestAndResponseIs added in v1.0.0

func (apiCtx *APIContext) AssertTimeBetweenRequestAndResponseIs(timeInterval time.Duration) error

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

func (*APIContext) DebugPrintResponseBody added in v1.0.0

func (apiCtx *APIContext) DebugPrintResponseBody() error

DebugPrintResponseBody prints last response from request.

func (*APIContext) DebugStart added in v1.0.0

func (apiCtx *APIContext) DebugStart() error

DebugStart starts debugging mode

func (*APIContext) DebugStop added in v1.0.0

func (apiCtx *APIContext) DebugStop() error

DebugStop stops debugging mode

func (*APIContext) GenerateFloat64 added in v1.0.0

func (apiCtx *APIContext) GenerateFloat64(from, to float64, cacheKey string) error

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

func (*APIContext) GenerateRandomInt added in v1.0.0

func (apiCtx *APIContext) GenerateRandomInt(from, to int, cacheKey string) error

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

func (*APIContext) GenerateTimeAndTravel added in v1.0.0

func (apiCtx *APIContext) GenerateTimeAndTravel(timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

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

func (*APIContext) GeneratorRandomRunes added in v1.0.0

func (apiCtx *APIContext) GeneratorRandomRunes(charset string) func(from, to int, cacheKey string) error

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

func (*APIContext) GeneratorRandomSentence added in v1.0.0

func (apiCtx *APIContext) GeneratorRandomSentence(charset string, wordMinLength, wordMaxLength int) func(from, to int, cacheKey string) error

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

func (*APIContext) GetLastResponse added in v0.14.1

func (apiCtx *APIContext) GetLastResponse() (*http.Response, error)

GetLastResponse returns last HTTP(s) response.

func (*APIContext) GetLastResponseBody added in v0.14.1

func (apiCtx *APIContext) 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 (*APIContext) GetPreparedRequest added in v0.14.1

func (apiCtx *APIContext) GetPreparedRequest(cacheKey string) (*http.Request, error)

GetPreparedRequest returns prepared request from cache or error if failed

func (*APIContext) GetTimeAndTravel added in v1.0.0

func (apiCtx *APIContext) GetTimeAndTravel(t time.Time, timeDirection timeutils.TimeDirection, timeDuration time.Duration, cacheKey string) error

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

func (*APIContext) RequestPrepare added in v1.0.0

func (apiCtx *APIContext) RequestPrepare(method, urlTemplate, cacheKey string) error

RequestPrepare prepares new request and saves it in cache under cacheKey

func (*APIContext) RequestSend added in v1.0.0

func (apiCtx *APIContext) RequestSend(cacheKey string) error

RequestSend sends previously prepared HTTP(s) request.

func (*APIContext) RequestSendWithBodyAndHeaders added in v1.0.0

func (apiCtx *APIContext) RequestSendWithBodyAndHeaders(method, urlTemplate string, bodyAndHeaderTemplate string) error
	RequestSendWithBodyAndHeaders 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 (*APIContext) RequestSetBody added in v1.0.0

func (apiCtx *APIContext) RequestSetBody(cacheKey, bodyTemplate string) error

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

func (*APIContext) RequestSetCookies added in v1.0.0

func (apiCtx *APIContext) RequestSetCookies(cacheKey, cookiesTemplate string) error

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

func (*APIContext) RequestSetForm added in v1.0.0

func (apiCtx *APIContext) RequestSetForm(cacheKey, formTemplate string) error

RequestSetForm 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 (*APIContext) RequestSetHeaders added in v1.0.0

func (apiCtx *APIContext) RequestSetHeaders(cacheKey, headersTemplate string) error

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

func (*APIContext) ResetState added in v0.14.1

func (apiCtx *APIContext) ResetState(isDebug bool)

ResetState resets state of APIContext to initial.

func (*APIContext) Save added in v1.0.0

func (apiCtx *APIContext) Save(valueTemplate, cacheKey string) error

Save saves into cache arbitrary passed data.

func (*APIContext) SaveHeader added in v1.0.0

func (apiCtx *APIContext) SaveHeader(name, cacheKey string) error

SaveHeader saves from last response header value under given cache key

func (*APIContext) SaveNode added in v1.0.0

func (apiCtx *APIContext) SaveNode(dataFormat format.DataFormat, exprTemplate, cacheKey string) error

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

func (*APIContext) SetCache added in v0.14.1

func (apiCtx *APIContext) SetCache(c cache.Cache)

SetCache sets new Cache for APIContext.

func (*APIContext) SetDebugger added in v0.14.1

func (apiCtx *APIContext) SetDebugger(d debugger.Debugger)

SetDebugger sets new debugger for APIContext.

func (*APIContext) SetJSONFormatter added in v0.14.1

func (apiCtx *APIContext) SetJSONFormatter(jf formatter.Formatter)

SetJSONFormatter sets new JSON formatter for APIContext.

func (*APIContext) SetJSONPathFinder added in v0.14.1

func (apiCtx *APIContext) SetJSONPathFinder(r pathfinder.PathFinder)

SetJSONPathFinder sets new JSON pathfinder for APIContext.

func (*APIContext) SetRequestDoer added in v0.14.1

func (apiCtx *APIContext) SetRequestDoer(r httpctx.RequestDoer)

SetRequestDoer sets new RequestDoer for APIContext.

func (*APIContext) SetSchemaReferenceValidator added in v0.14.1

func (apiCtx *APIContext) SetSchemaReferenceValidator(j validator.SchemaValidator)

SetSchemaReferenceValidator sets new schema ReferenceValidator for APIContext.

func (*APIContext) SetSchemaStringValidator added in v0.14.1

func (apiCtx *APIContext) SetSchemaStringValidator(j validator.SchemaValidator)

SetSchemaStringValidator sets new schema StringValidator for APIContext.

func (*APIContext) SetTemplateEngine added in v0.14.1

func (apiCtx *APIContext) SetTemplateEngine(t template.Engine)

SetTemplateEngine sets new template Engine for APIContext.

func (*APIContext) SetXMLFormatter added in v0.14.1

func (apiCtx *APIContext) SetXMLFormatter(xf formatter.Formatter)

SetXMLFormatter sets new XML formatter for APIContext.

func (*APIContext) SetXMLPathFinder added in v0.14.1

func (apiCtx *APIContext) SetXMLPathFinder(r pathfinder.PathFinder)

SetXMLPathFinder sets new XML pathfinder for APIContext.

func (*APIContext) SetYAMLFormatter added in v0.14.1

func (apiCtx *APIContext) SetYAMLFormatter(yd formatter.Formatter)

SetYAMLFormatter sets new YAML formatter for APIContext.

func (*APIContext) SetYAMLPathFinder added in v0.14.1

func (apiCtx *APIContext) SetYAMLPathFinder(r pathfinder.PathFinder)

SetYAMLPathFinder sets new YAML pathfinder for APIContext.

func (*APIContext) Wait added in v1.0.0

func (apiCtx *APIContext) Wait(timeInterval time.Duration) error

Wait waits for given timeInterval amount of time

type BodyHeaders added in v0.7.4

type BodyHeaders struct {

	// Body should contain HTTP(s) request body
	Body any

	// 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.

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