Documentation
¶
Index ¶
- type Scenario
- func (s *Scenario) IGenerateARandomNumberInTheRangeFromToAndSaveItAs(numberType string, from, to int, cacheKey string) error
- func (s *Scenario) IGenerateARandomRunesOfLengthWithCharactersAndSaveItAs(from, to int, charset string, cacheKey string) error
- func (s *Scenario) IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAs(minWordLength, maxWordLength int) func(from, to int, charset string, cacheKey string) error
- func (s *Scenario) IGenerateCurrentTimeAndTravelByAndSaveItAs(timeDirection, timeDuration, cacheKey string) error
- func (s *Scenario) IGenerateRandomBoolValueAndSaveItAs(cacheKey string) error
- func (s Scenario) IPrepareNewRequestToAndSaveItAs(method, urlTemplate, cacheKey string) error
- func (s *Scenario) IPrintLastResponseBody() error
- func (s *Scenario) ISaveAs(value, cacheKey string) error
- func (s *Scenario) ISaveFromTheLastResponseJSONNodeAs(expr, cacheKey string) error
- func (s Scenario) ISendRequest(cacheKey string) error
- func (s *Scenario) ISendRequestToWithBodyAndHeaders(method, urlTemplate string, reqBody *godog.DocString) error
- func (s Scenario) ISetFollowingBodyForPreparedRequest(cacheKey string, bodyTemplate *godog.DocString) error
- func (s Scenario) ISetFollowingCookiesForPreparedRequest(cacheKey string, cookies *godog.DocString) error
- func (s Scenario) ISetFollowingHeadersForPreparedRequest(cacheKey string, headersTemplate *godog.DocString) error
- func (s *Scenario) IStartDebugMode() error
- func (s *Scenario) IStopDebugMode() error
- func (s *Scenario) IStopScenarioExecution() error
- func (s *Scenario) IValidateJSONNodeWithSchemaReference(expr, reference string) error
- func (s *Scenario) IValidateJSONNodeWithSchemaString(expr string, jsonSchema *godog.DocString) error
- func (s *Scenario) IValidateLastResponseBodyWithFollowingSchema(schemaBytes *godog.DocString) error
- func (s *Scenario) IValidateLastResponseBodyWithSchema(reference string) error
- func (s *Scenario) IWait(timeInterval string) error
- func (s *Scenario) TheJSONNodeShouldBe(expr, goType string) error
- func (s *Scenario) TheJSONNodeShouldBeOfValue(expr, dataType, dataValue string) error
- func (s *Scenario) TheJSONNodeShouldBeSliceOfLength(expr string, length int) error
- func (s *Scenario) TheJSONNodeShouldMatchRegExp(expr, regExpTemplate string) error
- func (s *Scenario) TheJSONNodeShouldNotBe(expr, goType string) error
- func (s *Scenario) TheJSONResponseShouldHaveNode(expr string) error
- func (s *Scenario) TheJSONResponseShouldHaveNodes(nodesExpr string) error
- func (s *Scenario) TheResponseBodyShouldHaveFormat(dataType string) error
- func (s *Scenario) TheResponseShouldHaveCookie(name string) error
- func (s *Scenario) TheResponseShouldHaveCookieOfValue(name, valueTemplate string) error
- func (s *Scenario) TheResponseShouldHaveHeader(name string) error
- func (s *Scenario) TheResponseShouldHaveHeaderOfValue(name, value string) error
- func (s *Scenario) TheResponseStatusCodeShouldBe(code int) error
- func (s *Scenario) TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualTo(timeInterval string) error
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 (Scenario) IPrepareNewRequestToAndSaveItAs ¶
IPrepareNewRequestToAndSaveItAs prepares new request and saves it in cache under cacheKey.
func (*Scenario) IPrintLastResponseBody ¶
IPrintLastResponseBody prints response body from last scenario request
func (*Scenario) ISaveFromTheLastResponseJSONNodeAs ¶
ISaveFromTheLastResponseJSONNodeAs saves from last response json node under given cache key.
func (Scenario) ISendRequest ¶
ISendRequest sends previously prepared HTTP(s) request.
func (*Scenario) ISendRequestToWithBodyAndHeaders ¶
func (s *Scenario) ISendRequestToWithBodyAndHeaders(method, urlTemplate string, reqBody *godog.DocString) error
ISendRequestToWithBodyAndHeaders 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 format acceptable by Deserializer with keys "body" and "headers". Internally method will marshal request body to JSON format and add it to request. If you want to send request body in arbitrary data format, use step-by-step flow containing following methods: IPrepareNewRequestToAndSaveItAs - creates request object and save it to cache ISetFollowingHeadersForPreparedRequest - sets header for saved request ISetFollowingBodyForPreparedRequest - sets body for saved request ISendRequest - sends previously saved request Because method ISetFollowingBodyForPreparedRequest pass any bytes to HTTP(s) request body without any mutation.
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 ¶
IStartDebugMode starts debugging mode
func (*Scenario) IStopDebugMode ¶
IStopDebugMode stops debugging mode
func (*Scenario) IStopScenarioExecution ¶ added in v1.0.12
IStopScenarioExecution stops scenario execution
func (*Scenario) IValidateJSONNodeWithSchemaReference ¶ added in v1.0.15
IValidateJSONNodeWithSchemaReference validates last response body JSON node against jsonSchema as provided in reference
func (*Scenario) IValidateJSONNodeWithSchemaString ¶ added in v1.0.15
func (s *Scenario) IValidateJSONNodeWithSchemaString(expr string, jsonSchema *godog.DocString) error
IValidateJSONNodeWithSchemaString validates last response body JSON node against jsonSchema
func (*Scenario) IValidateLastResponseBodyWithFollowingSchema ¶ added in v1.0.8
IValidateLastResponseBodyWithFollowingSchema validates last response body against JSON schema provided by user.
func (*Scenario) IValidateLastResponseBodyWithSchema ¶ added in v1.0.1
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) IWait ¶
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) TheJSONNodeShouldBe ¶
TheJSONNodeShouldBe checks whether JSON node from last response body is of provided type. goType may be one of: nil, string, int, float, bool, map, slice. node should be expression acceptable by qjson package against JSON node from last response body.
func (*Scenario) TheJSONNodeShouldBeOfValue ¶
TheJSONNodeShouldBeOfValue finds JSON node from provided expression and compares it to, expected by user value of given by user type, available data types are listed in switch section in each case directive.
func (*Scenario) TheJSONNodeShouldBeSliceOfLength ¶
TheJSONNodeShouldBeSliceOfLength finds JSON node from provided expression and checks whether given JSON node is slice and has given length.
func (*Scenario) TheJSONNodeShouldMatchRegExp ¶ added in v1.0.15
TheJSONNodeShouldMatchRegExp checks whether JSON node matches provided regExp
func (*Scenario) TheJSONNodeShouldNotBe ¶
TheJSONNodeShouldNotBe checks whether JSON node from last response body is not of provided type. goType may be one of: nil, string, int, float, bool, map, slice. node should be expression acceptable by qjson package against JSON node from last response body.
func (*Scenario) TheJSONResponseShouldHaveNode ¶
TheJSONResponseShouldHaveNode checks whether last response body contains given JSON node.
func (*Scenario) TheJSONResponseShouldHaveNodes ¶
TheJSONResponseShouldHaveNodes checks whether last request body has keys defined in string separated by comma nodeExpr should be valid according to qjson library expressions separated by comma (,)
func (*Scenario) TheResponseBodyShouldHaveFormat ¶ added in v1.0.12
TheResponseBodyShouldHaveFormat checks whether last response body has given data type available data types are listed in dataformat package
func (*Scenario) TheResponseShouldHaveCookie ¶ added in v1.0.14
TheResponseShouldHaveCookie checks whether last HTTP(s) response has cookie of given name.
func (*Scenario) TheResponseShouldHaveCookieOfValue ¶ added in v1.0.14
TheResponseShouldHaveCookieOfValue checks whether last HTTP(s) response has cookie of given name and value.
func (*Scenario) TheResponseShouldHaveHeader ¶
TheResponseShouldHaveHeader checks whether last HTTP response has given header.
func (*Scenario) TheResponseShouldHaveHeaderOfValue ¶
TheResponseShouldHaveHeaderOfValue checks whether last HTTP response has given header with provided value.
func (*Scenario) TheResponseStatusCodeShouldBe ¶
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