Categorygithub.com/pawelWritesCode/gdutils
modulepackage
0.14.1
Repository: https://github.com/pawelwritescode/gdutils.git
Documentation: pkg.go.dev

# 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

Related project:

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:

NAMEDESCRIPTION
Sending HTTP(s) requests:
ISendRequestToWithBodyAndHeadersSends HTTP(s) request with provided body and headers.
IPrepareNewRequestToAndSaveItAsPrepare HTTP(s) request
ISetFollowingHeadersForPreparedRequestSets provided headers for previously prepared request
ISetFollowingFormForPreparedRequestSets provided form for previously prepared request
ISetFollowingCookiesForPreparedRequestSets provided cookies for previously prepared request
ISetFollowingBodyForPreparedRequestSets body for previously prepared request
ISendRequestSends previously prepared HTTP(s) request
Random data generation:
IGenerateARandomIntInTheRangeToAndSaveItAsGenerates random integer from provided range and save it under provided cache key
IGenerateARandomFloatInTheRangeToAndSaveItAsGenerates random float from provided range and save it under provided cache key
IGenerateARandomRunesInTheRangeToAndSaveItAsCreates generator for random strings from provided charset in provided range
IGenerateARandomSentenceInTheRangeFromToWordsAndSaveItAsCreates generator for random sentence from provided charset in provided range
IGetTimeAndTravelByAndSaveItAsAccepts time object and move in time by given time interval
IGenerateCurrentTimeAndTravelByAndSaveItAsCreates current time object and move in time by given time interval
Preserving data:
ISaveFromTheLastResponseNodeAsSaves from last response body JSON node under given cacheKey key
ISaveAsSaves into cache arbitrary passed value
Debugging:
IPrintLastResponseBodyPrints last response from request
IStartDebugModeStarts debugging mode
IStopDebugModeStops debugging mode
Flow control:
IWaitStops test execution for provided amount of time
Assertions:
TheResponseShouldHaveHeaderChecks whether last HTTP(s) response has given header
TheResponseShouldHaveHeaderOfValueChecks whether last HTTP(s) response has given header with provided value
TheResponseStatusCodeShouldBeChecks last HTTP(s) response status code
TheResponseBodyShouldHaveTypeChecks whether last HTTP(s) response body has given data format
TheResponseShouldHaveNodeChecks whether last response body contains given key
TheNodeShouldBeOfValueCompares json node value from expression to expected by user
TheNodeShouldBeChecks whether node from last HTTP(s) response body is of provided type
TheNodeShouldNotBeChecks whether node from last response body is not of provided type
TheResponseShouldHaveNodesChecks whether last HTTP(s) response body JSON has given nodes
TheNodeShouldMatchRegExpChecks whether last HTTP(s) response body JSON node matches regExp
TheNodeShouldBeSliceOfLengthchecks whether given key is slice and has given length
IValidateLastResponseBodyWithSchemaReferenceValidates last HTTP(s) response body against provided in reference JSON schema
IValidateLastResponseBodyWithSchemaStringValidates last HTTP(s) response body against provided JSON schema
IValidateJSONNodeWithSchemaStringValidates last HTTP(s) response body JSON node against provided JSON schema
IValidateJSONNodeWithSchemaReferenceValidates last HTTP(s) response body JSON node against provided in reference JSON schema
TimeBetweenLastHTTPRequestResponseShouldBeLessThanOrEqualToAsserts that last HTTP(s) request-response time is <= than expected
TheResponseShouldHaveCookieChecks whether last HTTP(s) response has given cookie
TheResponseShouldHaveCookieOfValueChecks whether last HTTP(s) response has given cookie of given value

# Packages

Package pkg holds packages used for steps.

# Functions

NewAPIContext returns *APIContext.
NewDefaultAPIContext returns *APIContext with default services.

# Structs

APIContext holds utility services for working with HTTP(s) API.
BodyHeaders is entity that holds information about request body and request headers.
Formatters is container for entities that know how to serialize and deserialize data.
PathFinders is container for different data types pathfinders.
SchemaValidators is container for JSON schema validators.