pipeline

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ReportTimeFormat = "2006-01-02T15-04-05.000Z"

Variables

This section is empty.

Functions

func RawReports

func RawReports() ([]map[string]any, error)

RawReports return all the reports in the report directory without unmarshalling them

Types

type Pipeline

type Pipeline struct {
	TestCases  map[string][]fetcher.TestCase `json:"testCases"`  // TestCases are the collection of TestCase for each endpoint (definition file)
	Validators []validators.Validator        `json:"validators"` // Validators are the validators that will be applied to the items in the pipeline
	// contains filtered or unexported fields
}

Pipeline represents the validation pipeline

func NewPipeline

func NewPipeline() (Pipeline, error)

NewPipeline creates a new validation pipeline without any validators

func NewPipelineWithValidators

func NewPipelineWithValidators(validators ...validators.Validator) (Pipeline, error)

NewPipelineWithValidators creates a new validation pipeline with the given validators already added

func (*Pipeline) AddValidator

func (p *Pipeline) AddValidator(validator validators.Validator)

AddValidator adds a validator to the end of the validation pipeline

func (*Pipeline) Reload

func (p *Pipeline) Reload() error

Reload re-populates the Pipeline.TestCases collection

func (*Pipeline) RemoveValidator

func (p *Pipeline) RemoveValidator(name string)

RemoveValidator removes a validator from the validation pipeline identified by its name

func (*Pipeline) Validate

func (p *Pipeline) Validate() Report

Validate validates all the test cases in the pipeline and returns a Report

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

func GetReport

func GetReport(filename string) (*Report, error)

func Reports

func Reports() ([]Report, error)

Reports returns all the reports in the report directory

type ReportTime

type ReportTime time.Time

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 TestCase

type TestCase 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
}

TestCase represents an item in the validation pipeline

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 ValidatorResult

type ValidatorResult struct {
	Name    string                     `json:"name"`    // Name is the name of the validator
	Status  validators.ValidatorStatus `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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL