step

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBodyExtractor

func NewBodyExtractor() extractor

func NewHTTPValidator

func NewHTTPValidator() validator

NewHTTPValidator instantiates a new HTTPValidator

func NewTemplateInterpolator

func NewTemplateInterpolator() *templateInterpolator

NewTemplateInterpolator instantiates a new template interpolator

Types

type Executor added in v0.1.6

type Executor interface {
	Do(Request) (*http.Response, error)
}

func NewHTTPExecutor

func NewHTTPExecutor(client http.Client) Executor

NewHTTPExecutor instantiates a new http executor

func NewRemoteHTTPExecutor added in v0.2.0

func NewRemoteHTTPExecutor(client *native.Client, apiKey string, region string) (Executor, error)

NewRemoteHTTPExecutor instantiates a new http executor

type ExpectBody

type ExpectBody struct {
	Selector *string `yaml:"selector" json:"selector"`
	KeysOnly *bool   `yaml:"keys_only" json:"keys_only"`
	Subset   *bool   `yaml:"subset" json:"subset"`
	Is       string  `yaml:"is" json:"is"`
}

type ExpectedResponse

type ExpectedResponse struct {
	Code    *int          `yaml:"code" json:"code"`
	Headers *Headers      `yaml:"headers" json:"headers"`
	Body    []*ExpectBody `yaml:"body" json:"body" validate:"expectBody"`
}

type Export

type Export map[string]string

type Exported

type Exported map[string]interface{}

func (Exported) Generic

func (e Exported) Generic() map[string]interface{}

type Headers

type Headers map[string][]string

func (*Headers) UnmarshalYAML

func (r *Headers) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML unmarshalls yaml in the format

         headers:
           header1: 1
           header1: 4
           header2: [2,3]
			  header3: 1

into Headers to result in

map{
  header1: [1,4],
  header2: [2,3],
  header3: [1],
}

type PreparedStep

type PreparedStep Step

PreparedStep is the same as step, but with replaced template tokens

type Request

type Request struct {
	// Type if the method of the request
	Type                string  `yaml:"method" json:"method" validate:"required"`
	Endpoint            string  `yaml:"endpoint" json:"endpoint" validate:"required"`
	Headers             Headers `yaml:"headers" json:"headers"`
	Body                string  `yaml:"body" json:"body"`
	SkipSSLVerification *bool   `yaml:"skip_ssl_verify" json:"skip_ssl_verify"`
}

Request is a single step request data

type Result

type Result struct {
	Step     PreparedStep
	Timings  http.Timings
	Exported Exported
	Valid    ValidationResult
}

Result has all the data about the step execution

func (*Result) AddErr

func (r *Result) AddErr(key string, err error)

func (Result) OK

func (r Result) OK() bool

type Runner

type Runner interface {
	Run(Step, variables.Variables) (Result, error)
}

Runner takes a step and variables and checks if it returns the expected data

func NewRunner

func NewRunner(
	executor Executor,
	validator validator,
	interpolator interpolator,
	extractor extractor) Runner

NewRunner instantiates a new HTTPRunner

type Step

type Step struct {
	ID        string              `yaml:"id" json:"id" validate:"required"`
	Variables variables.Variables `yaml:"variables" json:"variables"`
	Request   Request             `yaml:"request" json:"request" validate:"required"`
	Response  ExpectedResponse    `yaml:"expect" json:"expect"`
	Export    Export              `yaml:"export" json:"export"`
}

Step is the data for a single endpoint

type ValidationResult

type ValidationResult struct {
	Errors map[string]string // a list of error keys and more information about what caused them
}

ValidationResult holds information if the validation succeeded or not and what errors were encountered if any

func (ValidationResult) OK

func (r ValidationResult) OK() bool

OK returns overall check status, true only if every other check passes

Jump to

Keyboard shortcuts

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