Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefinitionsLocation ¶
func DefinitionsLocation() string
DefinitionsLocation returns the location of the definitions directory
func RawReports ¶
RawReports return all the reports in the report directory without unmarshalling them
func ReportLocation ¶
func ReportLocation() string
ReportLocation returns the output directory where all reports are stored
Types ¶
type EndpointDefinition ¶
type EndpointDefinition struct {
FileName string
Name string `toml:"name"` // Name is the name of the endpoint
IsEnabled bool `toml:"enabled"` // IsEnabled is a boolean that indicates if the endpoint is enabled (not contained in the definition)
BaseUrl string `toml:"base-url"` // BaseUrl is the base path of the endpoint
ExcludedValidators []string `toml:"excluded-validators"` // ExcludedValidators is a list of validators that should not be used for this endpoint
QueryParameters []query.Definition `toml:"query"` // QueryParameters are all the query parameters that should be added to the call
Format string `toml:"format"` // Format is the response format of the
Variables []variables.Definition `toml:"variable"` // Variables are all the variables that should be interpolated in the base url and the query parameters
ResultSchema response.Schema `toml:"result"` // ResultSchema describes how the response should look like
}
EndpointDefinition is the definition of an endpoint to test with all its query parameters, variables and its result schema
func EndpointDefinitions ¶
func EndpointDefinitions() ([]EndpointDefinition, error)
EndpointDefinitions uses parseDefinition to parse all the definitions found in the definitions/ directory. Directories and Files that start with the ignorePrefix are ignored.
type Pipeline ¶
type Pipeline struct {
TestCases map[string][]PipelineTestCase `json:"testCases"` // TestCases are the collection of PipelineTestCase for each endpoint (definition file)
Validators []Validator `json:"validators"` // Validators are the validators that will be applied to the items in the pipeline
}
Pipeline represents the validation pipeline
func NewPipeline ¶
NewPipeline creates a new validation pipeline without any validators
func NewPipelineWithValidators ¶
NewPipelineWithValidators creates a new validation pipeline with the given validators already added
func (*Pipeline) AddValidator ¶
AddValidator adds a validator to the end of the validation pipeline
func (*Pipeline) RemoveValidator ¶
RemoveValidator removes a validator from the validation pipeline identified by its name
type PipelineTestCase ¶
type PipelineTestCase struct {
SchemaEntries []response.SchemaEntry `json:"schemaEntries"` // SchemaEntries are the schema definitions of every field in the items Data
Data map[string]any `json:"data"` // Data is the raw response data mapped in a map
Url string `json:"url"` // Url is the request url of the item
EndpointName string `json:"endpointName"` // EndpointName is the name of the endpoint in the definition file
Code int `json:"code"` // Code is the response code of the request
ExcludedValidators []string `json:"excludedValidators"` // ExcludedValidators is a list of validators that should be excluded from the validation
}
PipelineTestCase represents an item in the validation pipeline
type Report ¶
type Report struct {
Id string `json:"id"` // Id is a unique identifier for each report
Time ReportTime `json:"time"` // Time is the timestamp of the report
Endpoints []ValidatedEndpoint `json:"endpoints"` // Endpoints is a collection of ValidatedEndpoint holding the validation results
}
Report is a report of a test run
type ReportTime ¶
func (ReportTime) MarshalJSON ¶
func (t ReportTime) MarshalJSON() ([]byte, error)
func (ReportTime) String ¶
func (t ReportTime) String() string
func (*ReportTime) UnmarshalJSON ¶
func (t *ReportTime) UnmarshalJSON(b []byte) error
type TestCaseResult ¶
type TestCaseResult struct {
Url string `json:"url"` // Url is the url of the api call (with query parameters)
ValidatorResults []ValidatorResult `json:"validatorResults"` // ValidatorResults is the collection of ValidatorResult that describe the result of each validator
}
TestCaseResult is the result of validating a single api call
type ValidatedEndpoint ¶
type ValidatedEndpoint struct {
EndpointName string `json:"endpointName"` // EndpointName is he name of the endpoint
TestCaseResults []TestCaseResult `json:"testCaseResults"` // TestCaseResults are the collection of TestCaseResult that describe the result of validating a single api call
}
ValidatedEndpoint is the collection of results for each endpoint (definition) that are generated for each different call to the endpoint (produced by the multiple variable values)
type Validator ¶
type Validator interface {
Name() string // Name returns the name of the validator
Validate(item PipelineTestCase) error // Validate validates the given item and return nil on success or an error on failure
IsFatal() bool // IsFatal returns true if the validator is fatal and the pipeline should stop on failure
}
Validator is an interface that all validators in the pipeline must implement
type ValidatorResult ¶
type ValidatorResult struct {
Name string `json:"name"` // Name is the name of the validator
Status string `json:"status"` // Status is the status of the validator (success/fail/skipped)
Message string `json:"message"` // Message is the error message of the validator
}
ValidatorResult is the output of a single validator