Documentation
¶
Index ¶
- type DataResolver
- type EntityTrait
- type Expectation
- type LogStyle
- type Logger
- type Operation
- type OperationAccess
- type OperationData
- type OperationIterator
- type OperationResult
- type OperationResults
- type Parameter
- type ParameterAccess
- type ParameterIterator
- type ParameterSource
- type ParameterTuple
- type ProjectInfo
- type Request
- type RequestEnrichment
- type RequestEnrichmentParameters
- type Script
- type Security
- type Set
- type Spec
- type StringParameters
- type TabFn
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataResolver ¶
type DataResolver interface { // Host attempts to come up with a valid host name based on the input // host hint, which is a spec-specific host identifier. // F.e. it's a name for OAS3, but may be index or a literal host for other // spec standards. Host(hostHint string) ParameterSource Security(secName string) Security Response(status int64, CT string) Validator }
DataResolver is an interface to resolution of internal spec data based on user input such as host name or ID, security name, etc.
type EntityTrait ¶
type EntityTrait struct {
Log Logger
}
EntityTrait contains basic functions shared by multiple different app components, such as logging.
type Expectation ¶
type Expectation func(*OperationResult) bool
Expectation is a function to check various properties of an HTTP request. A list of various expectation compose a Validator.
type LogStyle ¶
type LogStyle interface { Default(...interface{}) string URL(...interface{}) string Method(...interface{}) string Op(...interface{}) string OK(...interface{}) string Failure(...interface{}) string Success(...interface{}) string Error(...interface{}) string ID(...interface{}) string ValueExpected(...interface{}) string ValueActual(...interface{}) string Value(...interface{}) string }
LogStyle is an interface to log styling.
type Logger ¶
type Logger interface { NOMESSAGE(msg string, args ...interface{}) Parameters(name string, params ParameterSource) Print(l int64, msg string, args ...interface{}) Usage() Error(err error) LoadingSpec(path string) LoadingScript(path string) PrintOperations(ops OperationIterator) TestingProject(p ProjectInfo) TestingOperation(res Operation) UsingSecurity(sec Security) SecurityHasNoData(sec Security) Requesting(method string, url string) UsingParameterExample(paramName string, in string, container string, value string) Expecting(what string, v string) ExpectingProperty(what string, v string) HeaderHasNoValue(hdr string) ResponseHasWrongStatus(expectedStatus int, actualStatus int) ResponseHasWrongContentType(expectedCT string, actualCT string) ResponseHasWrongPropertyValue(propName string, expected string, actual string) OperationOK() OperationFail() SchemaOK(schemaName string) SchemaFail(schemaName string, errors []gojsonschema.ResultError) ScriptExecutionStart(node string) XError(err error, style LogStyle, tab TabFn) }
Logger - interface for test execution loggers.
type Operation ¶
type Operation interface { ID() string Name() string Description() string Method() string Path() string Data() *OperationData Result() *OperationResult Resolve() DataResolver GetRequest() (*http.Request, error) }
Operation is an interface for accessing operation properties.
type OperationAccess ¶
type OperationAccess interface { Operations() OperationIterator GetOperation(id string) Operation }
OperationAccess is an interafce for operation access.
type OperationData ¶
type OperationData struct { URL StringParameters Query RequestEnrichmentParameters Headers RequestEnrichmentParameters Body RequestEnrichmentParameters }
OperationData is an interface to access data from various sources (spec path, spec op, cli input, test output) needed in order to build an http.Request instance.
func (*OperationData) Load ¶
func (data *OperationData) Load(data2 *OperationData)
Load loads parameters from data2.
type OperationIterator ¶
type OperationIterator chan Operation
OperationIterator is an iterable channel to receive operations from.
type OperationResult ¶
type OperationResult struct { Success bool HTTPRequest *http.Request HTTPResponse *http.Response ResponseBytes []byte }
OperationResult describes the outcome of an operation test. It is bo te used as a possible source of data for subsequent tests.
func (*OperationResult) And ¶
func (r1 *OperationResult) And(r2 *OperationResult) *OperationResult
And creates a new OperationResult instance with the Success field assigned the result of r1.Success && r2.Success.
type OperationResults ¶
type OperationResults map[string]*OperationResult
OperationResults is a map of operation results.
type Parameter ¶
type Parameter struct { V ParameterAccess Source string }
Parameter is a pair of parameter value and name of it's source.
type ParameterAccess ¶
type ParameterAccess func() string
ParameterAccess is a function to provide a value for an operation. Values can be either literal or references. Reference values are used in scripts and look like "#opID.response[JSON_SELECTOR]". They are used to get certain values from one operation response as an input to another operation.
type ParameterIterator ¶
type ParameterIterator chan ParameterTuple
ParameterIterator is an iterable channel to receive tuples of parameter name & value.
type ParameterSource ¶
type ParameterSource interface {
Iterate() ParameterIterator
}
ParameterSource is an interface for a parameter source. Parameters may come from various places, such as API specs, CLI arguments & another test output.
type ParameterTuple ¶
ParameterTuple is a pair of parameter name and it's value.
type ProjectInfo ¶
ProjectInfo is a generic project information.
type Request ¶
type Request interface { Enrich(en RequestEnrichment) Execute() *OperationResult }
Request represents an operation HTTP request.
type RequestEnrichment ¶
RequestEnrichment is a utility type that extends a request instance with additional data.
type RequestEnrichmentParameters ¶
type RequestEnrichmentParameters interface { Set RequestEnrichment }
RequestEnrichmentParameters is used to enrich http.Request instances with parameters. Used for headers & query values.
type Security ¶
type Security interface { RequestEnrichment GetName() string }
Security is an interface for security mechanisms.
type Set ¶
type Set interface { Load(src ParameterSource) Reload() Require(paramName string) Validate() error Iterate() ParameterIterator }
Set is an interface to a set of named values used as input parameters for an operation. Operation parameters come from various sources at various stages of testing, some of them are required, some are optional.
type Spec ¶
type Spec interface { ProjectInfo OperationAccess }
Spec is an interface to access specification data.
type StringParameters ¶
StringParameters represent all the available parameters as a string value. At the moment it is used for building a URL.
type Validator ¶
type Validator interface { Validate(*OperationResult) *OperationResult Expect(Expectation) }
Validator implements validation/testing logic. It is specific to spec formats and comes from there (via Operation).