Documentation ¶
Index ¶
- func JSONResponse(result *contract.OperationResult, schema *api.Schema, log contract.Logger) bool
- func NewRequest(op contract.Operation, log contract.Logger) contract.Request
- func NoRequest(err error, log contract.Logger) contract.Request
- func Operation(op contract.Operation, enrichment *[]contract.RequestEnrichment, ...) *contract.OperationResult
- func Schema(data interface{}, schema *api.Schema, logger contract.Logger) bool
- func Success() *contract.OperationResult
- func TryJSONBooleanResponse(respData *[]byte, log contract.Logger) (res bool, err error)
- func TryJSONNumberResponse(respData *[]byte, log contract.Logger) (res int64, err error)
- func TryJSONStringResponse(respData *[]byte, log contract.Logger) (res string, err error)
- type JSONArray
- type JSONMap
- type NullRequest
- type NullValidator
- type Request
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONResponse ¶
JSONResponse tests JSON response bodies.
func NewRequest ¶
NewRequest creates a new Request instance.
func Operation ¶
func Operation( op contract.Operation, enrichment *[]contract.RequestEnrichment, v contract.Validator, log contract.Logger, ) *contract.OperationResult
Operation performs a test of an operation by requesting a path and validating the received response headers & content against the definitions founds in an OAS spec file.
func Success ¶
func Success() *contract.OperationResult
Success creates a new OperationResult instance with the Success field set to true to assure maximum SUCCESS.
func TryJSONBooleanResponse ¶
TryJSONBooleanResponse tries to unmarshal respData as a boolean.
func TryJSONNumberResponse ¶
TryJSONNumberResponse tries to unmarshal respData as a number.
Types ¶
type NullRequest ¶
type NullRequest struct {
errors.NullObjectPrototype
}
NullRequest is a placeholder request used when we can't have a real one.
func (*NullRequest) Enrich ¶
func (req *NullRequest) Enrich(en contract.RequestEnrichment)
Enrich reports an error.
func (*NullRequest) Execute ¶
func (req *NullRequest) Execute() *contract.OperationResult
Execute reports an error.
type NullValidator ¶
type NullValidator struct {
errors.NullObjectPrototype
}
NullValidator is used whenever we can't have a real one from DataResolver.Response(). Reports the contained error on every method call.
func NoValidator ¶
func NoValidator(err error, log contract.Logger) *NullValidator
NoValidator creates a new NullValidator instance.
func (*NullValidator) Expect ¶
func (v *NullValidator) Expect(ex contract.Expectation)
Expect adds an Expectation function to the list.
func (*NullValidator) Validate ¶
func (v *NullValidator) Validate(r *contract.OperationResult) *contract.OperationResult
Validate runs through the list of expectations and tests the HTTP request instance from the OperationResult against them.
type Request ¶
type Request struct { contract.EntityTrait HTTPRequest *http.Request HTTPClient *http.Client Result *contract.OperationResult }
Request represents an operation HTTP request. It contains native API objects, supplies data, tracks results and does logging.
func (*Request) Enrich ¶
func (req *Request) Enrich(en contract.RequestEnrichment)
Enrich extends the internal request with additional data.
func (*Request) Execute ¶
func (req *Request) Execute() *contract.OperationResult
Execute executes the request.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator tests an operation response for compliance with the expectations.
func NewValidator ¶
NewValidator creates a new Validator instance.
func (*Validator) Expect ¶
func (v *Validator) Expect(ex contract.Expectation)
Expect adds an Expectation function to the list.
func (*Validator) Validate ¶
func (v *Validator) Validate(r *contract.OperationResult) *contract.OperationResult
Validate runs through the list of expectations and tests the HTTP request instance from the OperationResult against them.