Documentation ¶
Overview ¶
test contains convenience types and functions used in BDD features
Index ¶
- func DoSequence(step func(it int) error, count int) error
- func DoThen(err error, next func() error) error
- func Expect(msg string) error
- func ExpectThen(msg string, next func() error) error
- type Client
- type PaymentData
- type ScenarioData
- type World
- func (w *World) APaymentWithId(id string) error
- func (w *World) APaymentWithIdAmount(id string, amount string) error
- func (w *World) APaymentWithIdNoOrganisation(id string) error
- func (w *World) ICreatePayments(count int) error
- func (w *World) ICreateThatPayment() error
- func (w *World) ICreatedANewPaymentWithId(id string) error
- func (w *World) ICreatedPayments(count int) error
- func (w *World) IDeleteAllData() error
- func (w *World) IDeleteThatPayment() error
- func (w *World) IDeleteThatPaymentWithoutSayingWhichVersion() error
- func (w *World) IDeleteVersionOfThatPayment(v int) error
- func (w *World) IDeletedThatPayment() error
- func (w *World) IGetAllPayments() error
- func (w *World) IGetPaymentsFromTo(from int, to int) error
- func (w *World) IGetPaymentsWithoutFromTo() error
- func (w *World) IGetThatPayment() error
- func (w *World) IGetTheRepoInfo() error
- func (w *World) IQueryTheHealthEndpoint() error
- func (w *World) IQueryTheMetricsEndpoint() error
- func (w *World) IShouldHaveAJson() error
- func (w *World) IShouldHaveAText() error
- func (w *World) IShouldHaveContentType(expected string) error
- func (w *World) IShouldHavePayments(expected int) error
- func (w *World) IShouldHaveStatusCode(expected int) error
- func (w *World) IUpdateThatPayment() error
- func (w *World) IUpdateVersionOfThatPayment(v int) error
- func (w *World) IUpdatedThatPayment() error
- func (w *World) NewData()
- func (w *World) ThatJsonShouldHaveA(path string) error
- func (w *World) ThatJsonShouldHaveInt(path string, expected int) error
- func (w *World) ThatJsonShouldHaveItems(expected int) error
- func (w *World) ThatJsonShouldHaveString(path string, expected string) error
- func (w *World) ThatPaymentHasVersion(v int) error
- func (w *World) ThatTextShouldMatch(expected string) error
- func (w *World) TheRepoShouldHaveItems(expected int) error
- func (w *World) TheServiceIsUp() error
- func (w *World) ThereAreNoPayments() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoSequence ¶
DoSequence performs the given step function, count times, in a sequence.
func DoThen ¶
doThen is similar to expectThen except that it works with actions that either return an error or nil. This is useful when chaining steps
func Expect ¶
expect is a convenience function that denotes this is the last expectation from the chain
func ExpectThen ¶
expectThen is a convenience function that helps to chain an expectation after another. If the given msg is not empty then that means an expectation failed, and we translate it into an error. Otherwise we proceed with next.
Types ¶
type Client ¶
type Client struct { ServerUrl string Resp *httpclient.Response Json map[string]interface{} Text string Err error // contains filtered or unexported fields }
Client is a convenience api so that we can run queries against an existing server and read responses from it. This is currently used in BDD scenarios
func (*Client) Delete ¶
Get performs a DELETE request on the given path and updates its last response record
func (*Client) Get ¶
Get performs a GET request on the given path and updates its last response record
func (*Client) HasJson ¶
HasJson is a convenience function that returns true if the client has a json content-type in its last response
func (*Client) HasText ¶
HasText is a convenience function that returns true if the client has a text/plain content-type in its last response
func (*Client) Post ¶
Post performs a POST request on the given path, with the given payload as json
type PaymentData ¶
PaymentData is a simplified representation of a payment, to be used in BDDs. Most of fields will be set by default, but here we declare the ones that are really significant in our tests
func (*PaymentData) ToJSON ¶
func (p *PaymentData) ToJSON() string
ToJSON returns a json string from the payment data Most values that are not critical for our tests will be set to arbitrary defaults
type ScenarioData ¶
type ScenarioData struct { // Holds a simplified representation of a Payment PaymentData *PaymentData // Generic datastructure where steps might store data // and read from it Subject interface{} }
a ScenarioData struct is data for a particular scenario Each scenario needs to have a clean struct, in order to avoid side effects
type World ¶
type World struct { Client *Client Data *ScenarioData // contains filtered or unexported fields }
a World is a simple context or container for features
func (*World) APaymentWithId ¶
APaymentWithId defines a new payment in the current scenario context with the given id, and default values for the organisation and amount
func (*World) APaymentWithIdAmount ¶
APaymentWithIdAmount defines a new payment in the current scenario context with the given id and amount
func (*World) APaymentWithIdNoOrganisation ¶
APaymentWithIdNoOrganisation defines a new payment in the current scenario context with the given id, but no organisation set
func (*World) ICreatePayments ¶
ICreatePayments repeats many times the process of creating a new payment and verifying it was created, in a sequence
func (*World) ICreateThatPayment ¶
ICreateThatPayment actually creates the payment defined in the world request data (as a string) by posting it to the payments endpoint, as json
func (*World) ICreatedANewPaymentWithId ¶
ICreatedANewPaymentWithId combines logic from previous steps in order to provide a convenience Given step for payment fixtures in more complex scenarios
func (*World) ICreatedPayments ¶
ICreatedPayments runs the ICreatePayments step and then verifies the repo info
func (*World) IDeleteAllData ¶
IDeleteAllData use the admin endpoints in order to delete all data
func (*World) IDeleteThatPayment ¶
IDeleteThatPayment sends a DELETE request for the payment defined in the scenario data. The delete operation requires a version information
func (*World) IDeleteThatPaymentWithoutSayingWhichVersion ¶
IDeleteThatPaymentWithoutSayingWhichVersion sends a DELETE request for the current payment, but does not specify a version
func (*World) IDeleteVersionOfThatPayment ¶
IDeleteVersionOfThatPayment deletes a specific version of payment
func (*World) IDeletedThatPayment ¶
IDeletedThatPayment combines logic from previous steps in order to provide a convenience Given step for payment fixtures in more complex scenarios
func (*World) IGetAllPayments ¶
IGetAllPayments performs a GET on the payments endpoint and stores the response details in the World context. This function fetches payments 0 to 19
func (*World) IGetPaymentsFromTo ¶
iGetPaymentsFromTo returns a subset of payments
func (*World) IGetPaymentsWithoutFromTo ¶
IGetPaymentsWithoutFromTo performs a GET on the payments endpoint and stores the response details in the World context. This function does not specify from/to query params
func (*World) IGetThatPayment ¶
IGetThatPayment sends a GET request for the payment defined in the scenario data.
func (*World) IGetTheRepoInfo ¶
IGetTheRepoInfo uses the admin endpoints in order to get the current repository info
func (*World) IQueryTheHealthEndpoint ¶
IQueryTheHealthEndpoint performs a GET on the healthcheck endpoint and stores the response details in the World context
func (*World) IQueryTheMetricsEndpoint ¶
iQueryTheMetricsEndpoint performs a GET on the metrics endpoint and stores the response details in the World context
func (*World) IShouldHaveAJson ¶
IShouldHaveAJson inspects the client's latest response and checks for a json document
func (*World) IShouldHaveAText ¶
IShouldHaveAText inspects the client's latest response and checks for a string
func (*World) IShouldHaveContentType ¶
IShouldHaveContentType expects the client to have the given content type in its last response
func (*World) IShouldHavePayments ¶
IShouldHavePayments fetches a list of payments and ensure the number of items returned is the expected
func (*World) IShouldHaveStatusCode ¶
IShouldHaveStatusCode expects the client to have the given status code in its last response
func (*World) IUpdateThatPayment ¶
IUpdateThatPayment sends a PUT request for the payment defined in the scenario data.
func (*World) IUpdateVersionOfThatPayment ¶
IUpdateVersionOfThatPayment updates a specific version of payment
func (*World) IUpdatedThatPayment ¶
IUpdatedThatPayment combines logic from previous steps in order to provide a convenience Given step for payment fixtures in more complex scenarios
func (*World) NewData ¶
func (w *World) NewData()
NewData creates a new, blank scenario data structure
func (*World) ThatJsonShouldHaveA ¶
ThatJsonShouldHaveA inspects the json, if any, in the current scenario data, and verifies the given json path exists
func (*World) ThatJsonShouldHaveInt ¶
ThatJsonShouldHaveString inspects the json, if any, in the client and looks for the given field, and verifies it is equal to the given expected int value
func (*World) ThatJsonShouldHaveItems ¶
ThatJsonShouldHaveItems inspects the json, if any, and checks whether the data field contains an array with the expected number of items
func (*World) ThatJsonShouldHaveString ¶
ThatJsonShouldHaveString inspects the json, if any, in the client and looks for the given field, and verifies it is equal to the given expected string value
func (*World) ThatPaymentHasVersion ¶
ThatPaymentHasVersion updates the version of the payment data in the current scenario data
func (*World) ThatTextShouldMatch ¶
ThatTextShouldMatch inspects the json, if any, in the client and looks for the given field.
func (*World) TheRepoShouldHaveItems ¶
TheRepoShouldHaveItems uses the admin repo info endpoint and verifies it returns the total number of items expected
func (*World) TheServiceIsUp ¶
TheServiceIsUp checks the health check is reponding propertly
func (*World) ThereAreNoPayments ¶
ThereAreNoPayments ensure there is no data. This requires the target system to be started with admin routes