Documentation ¶
Index ¶
- func MatchFixtureQuery(value string) (*regexp.Regexp, bool)
- func ParseArrayForFormData(params []interface{}, parent string, queryRespMap map[string]gjson.Result) ([]string, error)
- func ParseMapForFormData(params map[string]interface{}, parent string, index int, ...) ([]string, error)
- func ParsePath(httpPath string, queryRespMap map[string]gjson.Result) (string, error)
- func ParseQuery(queryString string, queryRespMap map[string]gjson.Result) (string, error)
- func ParseToApplicationJSON(params interface{}, queryRespMap map[string]gjson.Result) (interface{}, error)
- func ParseToFormData(params interface{}, queryRespMap map[string]gjson.Result) ([]string, error)
- type FixtureQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchFixtureQuery ¶
MatchFixtureQuery will attempt to find matches for a fixture query pattern returning a *Regexp which can be used to further parse and a boolean indicating a match was found.
func ParseArrayForFormData ¶ added in v1.21.6
func ParseArrayForFormData(params []interface{}, parent string, queryRespMap map[string]gjson.Result) ([]string, error)
ParseArrayForFormData is similar to parseMap but doesn't have to build the multi-depth keys. Form data arrays contain brackets with nothing inside the bracket to designate an array instead of a key value pair.
func ParseMapForFormData ¶ added in v1.21.6
func ParseMapForFormData(params map[string]interface{}, parent string, index int, queryRespMap map[string]gjson.Result) ([]string, error)
ParseMapForFormData recursively parses a map of string => interface{} until each leaf node has a terminal type (String, Int, etc) that can no longer be recursively traversed.
func ParsePath ¶
ParsePath will inspect the path to see if it has a query in the path for requests that operate on specific objects (for example, GET /v1/customers/:id or POST /v1/subscriptions/:id)
If a query is found, this returns the path with the value already in place. If there is no query, it returns the old path as-is.
func ParseQuery ¶
ParseQuery checks strings for possible queries and replaces the corresponding value in its place. The supported query format is:
$<name of fixture>:dot.path.to.field
func ParseToApplicationJSON ¶ added in v1.21.6
func ParseToApplicationJSON(params interface{}, queryRespMap map[string]gjson.Result) (interface{}, error)
ParseToApplicationJSON is the primary entrypoint into building the request data for v2 fixtures. The data will always be provided as an interface{} and this will need to use reflection to determine how to proceed. There are two primary paths here, `parseMap` and `ParseArray`, which will recursively traverse and convert the data
This returns an interface of clean application/json data to make the request.
func ParseToFormData ¶ added in v1.21.6
ParseToFormData is the primary entrypoint into building the request data for fixtures. The data will always be provided as an interface{} and this will need to use reflection to determine how to proceed. There are two primary paths here, `parseMap` and `ParseArray`, which will recursively traverse and convert the data
This returns an array of clean form data to make the request.
Types ¶
type FixtureQuery ¶
type FixtureQuery struct { Match string // The substring that matched the query pattern regex Name string Query string DefaultValue string }
FixtureQuery describes the query in fixture request
func ToFixtureQuery ¶
func ToFixtureQuery(value string) (FixtureQuery, bool)
ToFixtureQuery will parse a string into a fixtureQuery struct, additionally returning a bool indicating the value did contain a fixtureQuery.