defs

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scenario

type Scenario struct {
	// State is responsible for data flow inside one scenario.
	State *gdutils.State
}

Scenario represents Scenario unit in context of godog framework.

func (*Scenario) IGenerateARandomNumberInTheRangeFromToAndSaveItAs added in v1.0.12

func (s *Scenario) IGenerateARandomNumberInTheRangeFromToAndSaveItAs(numberType string, from, to int, cacheKey string) error

IGenerateARandomNumberInTheRangeFromToAndSaveItAs generates random number from provided range and preserve it in scenario cache under provided cacheKey.

func (*Scenario) IGenerateARandomRunesOfLengthWithCharactersAndSaveItAs added in v1.0.11

func (s *Scenario) IGenerateARandomRunesOfLengthWithCharactersAndSaveItAs(from, to int, charset string, cacheKey string) error

IGenerateARandomRunesOfLengthWithCharactersAndSaveItAs creates random runes generator func using provided charset. Returned func creates runes from provided range and preserve it under given cacheKey in scenario cache.

func (*Scenario) IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAs added in v1.0.8

func (s *Scenario) IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAs(minWordLength, maxWordLength int) func(from, to int, charset string, 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 scenario cache under provided cacheKey.

func (*Scenario) IGenerateCurrentTimeAndTravelByAndSaveItAs added in v1.0.12

func (s *Scenario) IGenerateCurrentTimeAndTravelByAndSaveItAs(timeDirection, timeDuration, cacheKey string) error

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

func (*Scenario) IGenerateRandomBoolValueAndSaveItAs added in v1.0.15

func (s *Scenario) IGenerateRandomBoolValueAndSaveItAs(cacheKey string) error

func (Scenario) IPrepareNewRequestToAndSaveItAs

func (s Scenario) IPrepareNewRequestToAndSaveItAs(method, urlTemplate, cacheKey string) error

IPrepareNewRequestToAndSaveItAs prepares new request and saves it in cache under cacheKey.

func (*Scenario) IPrintLastResponseBody

func (s *Scenario) IPrintLastResponseBody() error

IPrintLastResponseBody prints response body from last scenario request

func (*Scenario) ISaveAs added in v1.0.12

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

ISaveAs saves into cache arbitrary passed value

func (*Scenario) ISaveFromTheLastResponseNodeAs added in v1.0.16

func (s *Scenario) ISaveFromTheLastResponseNodeAs(dataFormat, expr, cacheKey string) error

ISaveFromTheLastResponseNodeAs saves from last response json node under given cache key.

func (Scenario) ISendRequest

func (s Scenario) ISendRequest(cacheKey string) error

ISendRequest sends previously prepared HTTP(s) request.

func (*Scenario) ISendRequestToWithBodyAndHeaders

func (s *Scenario) ISendRequestToWithBodyAndHeaders(method, urlTemplate string, reqBody *godog.DocString) 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 (Scenario) ISetFollowingBodyForPreparedRequest

func (s Scenario) ISetFollowingBodyForPreparedRequest(cacheKey string, bodyTemplate *godog.DocString) error

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

func (Scenario) ISetFollowingCookiesForPreparedRequest added in v1.0.14

func (s Scenario) ISetFollowingCookiesForPreparedRequest(cacheKey string, cookies *godog.DocString) error

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

func (Scenario) ISetFollowingHeadersForPreparedRequest

func (s Scenario) ISetFollowingHeadersForPreparedRequest(cacheKey string, headersTemplate *godog.DocString) error

ISetFollowingHeadersForPreparedRequest sets provided headers for previously prepared request. incoming data should be in format acceptable by injected s.State.Deserializer

func (*Scenario) IStartDebugMode

func (s *Scenario) IStartDebugMode() error

IStartDebugMode starts debugging mode

func (*Scenario) IStopDebugMode

func (s *Scenario) IStopDebugMode() error

IStopDebugMode stops debugging mode

func (*Scenario) IStopScenarioExecution added in v1.0.12

func (s *Scenario) IStopScenarioExecution() error

IStopScenarioExecution stops scenario execution

func (*Scenario) IValidateLastResponseBodyWithFollowingSchema added in v1.0.8

func (s *Scenario) IValidateLastResponseBodyWithFollowingSchema(schemaBytes *godog.DocString) error

IValidateLastResponseBodyWithFollowingSchema validates last response body against JSON schema provided by user.

func (*Scenario) IValidateLastResponseBodyWithSchema added in v1.0.1

func (s *Scenario) IValidateLastResponseBodyWithSchema(reference string) error

IValidateLastResponseBodyWithSchema validates last response body against JSON schema under provided reference. reference may be:

  • full OS path to JSON schema
  • relative path from JSON schema's dir which was passed in main_test to initialize *Scenario struct instance,
  • URL

func (*Scenario) IValidateNodeWithSchemaReference added in v1.0.16

func (s *Scenario) IValidateNodeWithSchemaReference(dataFormat, expr, reference string) error

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

func (*Scenario) IValidateNodeWithSchemaString added in v1.0.16

func (s *Scenario) IValidateNodeWithSchemaString(dataFormat, expr string, jsonSchema *godog.DocString) error

IValidateNodeWithSchemaString validates last response body JSON node against schema

func (*Scenario) IWait

func (s *Scenario) IWait(timeInterval string) error

IWait waits for provided time interval amount of time timeInterval should be string valid for time.ParseDuration func, for example: 3s, 1h, 30ms

func (*Scenario) TheNodeShouldBe added in v1.0.16

func (s *Scenario) TheNodeShouldBe(dataFormat, expr, 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 (*Scenario) TheNodeShouldBeOfValue added in v1.0.16

func (s *Scenario) TheNodeShouldBeOfValue(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 (*Scenario) TheNodeShouldBeSliceOfLength added in v1.0.16

func (s *Scenario) TheNodeShouldBeSliceOfLength(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 (*Scenario) TheNodeShouldMatchRegExp added in v1.0.16

func (s *Scenario) TheNodeShouldMatchRegExp(dataFormat, expr, regExpTemplate string) error

TheNodeShouldMatchRegExp checks whether last response body node matches provided regExp.

func (*Scenario) TheNodeShouldNotBe added in v1.0.16

func (s *Scenario) TheNodeShouldNotBe(dataFormat, expr, 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 (*Scenario) TheResponseBodyShouldHaveFormat added in v1.0.12

func (s *Scenario) TheResponseBodyShouldHaveFormat(dataFormat string) error

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

func (*Scenario) TheResponseShouldHaveCookie added in v1.0.14

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

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

func (*Scenario) TheResponseShouldHaveCookieOfValue added in v1.0.14

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

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

func (*Scenario) TheResponseShouldHaveHeader

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

TheResponseShouldHaveHeader checks whether last HTTP response has given header.

func (*Scenario) TheResponseShouldHaveHeaderOfValue

func (s *Scenario) TheResponseShouldHaveHeaderOfValue(name, value string) error

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

func (*Scenario) TheResponseShouldHaveNode added in v1.0.16

func (s *Scenario) TheResponseShouldHaveNode(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 (*Scenario) TheResponseShouldHaveNodes added in v1.0.16

func (s *Scenario) TheResponseShouldHaveNodes(dataFormat, nodesExpr 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 (*Scenario) TheResponseStatusCodeShouldBe

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

TheResponseStatusCodeShouldBe checks last response status code.

func (*Scenario) TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualTo added in v1.0.12

func (s *Scenario) TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualTo(timeInterval string) error

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

Jump to

Keyboard shortcuts

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