Documentation
¶
Overview ¶
Package assert defines atomic assertions to be used in tests
Index ¶
- func ArrayNotEmpty(a Accumulator, response *http.Response)
- func BookingStatus(a Accumulator, response *http.Response, expectedStatus string)
- func CriticArrayNotEmpty(a Accumulator, response *http.Response)
- func CriticFormat(a Accumulator, request *http.Request, response *http.Response)
- func Format(a Accumulator, request *http.Request, response *http.Response)
- func HeaderContains(a Accumulator, resp *http.Response, key, value string)
- func JourneysArrivalRadius(a Accumulator, request *http.Request, response *http.Response)
- func JourneysCount(a Accumulator, request *http.Request, response *http.Response)
- func JourneysDepartureRadius(a Accumulator, request *http.Request, response *http.Response)
- func JourneysTimeDelta(a Accumulator, request *http.Request, response *http.Response)
- func MockOKStatusResponse() *http.Response
- func OperatorFieldFormat(a Accumulator, response *http.Response)
- func ShouldHaveSingleAssertionResult(t *testing.T, ar []Result)
- func StatusCode(a Accumulator, resp *http.Response, statusCode int)
- func StatusCodeOK(a Accumulator, resp *http.Response)
- func UniqueIDs(a Accumulator, response *http.Response)
- type Accumulator
- type Assertion
- type CriticAssertion
- type DefaultAccumulator
- type NopAssertion
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayNotEmpty ¶
func ArrayNotEmpty(a Accumulator, response *http.Response)
ArrayNotEmpty checks that the response is not empty
func BookingStatus ¶
func BookingStatus(a Accumulator, response *http.Response, expectedStatus string)
func CriticArrayNotEmpty ¶
func CriticArrayNotEmpty(a Accumulator, response *http.Response)
CriticArrayNotEmpty checks that the response is not empty. A failure prevents the following assertions to be executed.
func CriticFormat ¶
func CriticFormat(a Accumulator, request *http.Request, response *http.Response)
CriticFormat is the same as Format, but a failure prevents the following assertions to be executed.
func Format ¶
func Format(a Accumulator, request *http.Request, response *http.Response)
Format checks if the response data has the expected format
func HeaderContains ¶
func HeaderContains(a Accumulator, resp *http.Response, key, value string)
HeaderContains checks if a given key is present in header, with associated value
func JourneysArrivalRadius ¶
func JourneysArrivalRadius(a Accumulator, request *http.Request, response *http.Response)
JourneysArrivalRadius checks that the response data respect the "arrivalRadius" query parameter
func JourneysCount ¶
func JourneysCount(a Accumulator, request *http.Request, response *http.Response)
JourneysCount checks that the response data respect the "count" query parameter
func JourneysDepartureRadius ¶
func JourneysDepartureRadius(a Accumulator, request *http.Request, response *http.Response)
JourneysDepartureRadius checks that the response data respect the "departureRadius" query parameter
func JourneysTimeDelta ¶
func JourneysTimeDelta(a Accumulator, request *http.Request, response *http.Response)
JourneysTimeDelta checks that the response data respect the "timeDelta" query parameter
func MockOKStatusResponse ¶
func OperatorFieldFormat ¶
func OperatorFieldFormat(a Accumulator, response *http.Response)
OperatorFieldFormat checks that the response data has well formated "operator" field
func StatusCode ¶
func StatusCode(a Accumulator, resp *http.Response, statusCode int)
StatusCode checks if a given response has an expected status code
StatusCode(*http.Response, int)
func StatusCodeOK ¶
func StatusCodeOK(a Accumulator, resp *http.Response)
StatusCodeOK checks if a given response has status 200 OK
func UniqueIDs ¶
func UniqueIDs(a Accumulator, response *http.Response)
UniqueIDs checks that all IDs (property "id"), if they exist, are unique.
Types ¶
type Accumulator ¶
type Accumulator interface { // Queue adds assertion to the queue for later execution Queue(...Assertion) // ExecuteAll executes assertions in sequence and stores the results. // If a CriticAssertion fails, execution is interrupted. ExecuteAll() // GetAssertionResults returns all results of executed assertions GetAssertionResults() []Result }
An Accumulator can run assertions, store and retrieve the corresponding AssertionResults
type CriticAssertion ¶
type CriticAssertion struct {
Assertion
}
A CriticAssertion is an Assertion, which success is critic for the execution of subsequent assertions.
func Critic ¶
func Critic(a Assertion) CriticAssertion
Critic converts an Assertion into a CriticAssertion
type DefaultAccumulator ¶
type DefaultAccumulator struct {
// contains filtered or unexported fields
}
DefaultAccumulator implements Asserter interface
func NewAccumulator ¶
func NewAccumulator() *DefaultAccumulator
NewAccumulator inits a *DefaultAssertionAccu
func (*DefaultAccumulator) ExecuteAll ¶
func (a *DefaultAccumulator) ExecuteAll()
ExecuteAll implements Accumulator.Run
func (*DefaultAccumulator) GetAssertionResults ¶
func (a *DefaultAccumulator) GetAssertionResults() []Result
GetAssertionResults implements Accumulator.GetAssertionResults
func (*DefaultAccumulator) Queue ¶
func (a *DefaultAccumulator) Queue(assertions ...Assertion)
Queue implements Accumulator.Queue.
type NopAssertion ¶
type NopAssertion struct {
// contains filtered or unexported fields
}
A NopAssertion returns stored error when executed
func (NopAssertion) Describe ¶
func (NopAssertion) Describe() string
Describe implements Assertion interface
func (NopAssertion) Execute ¶
func (n NopAssertion) Execute() error
Execute implements Assertion interface
type Result ¶
type Result struct { // Error, if any Err error // A string that summarizes the assertion AssertionDescription string }
An Result stores data and metadata about the result of a single assertion
func CheckAPICallSuccess ¶
CheckAPICallSuccess checks if requesting an endpoint returned an error
func NewAssertionResult ¶
NewAssertionResult initializes an AssertionResult