hrp

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const VERSION = "v0.1.0"

Variables

View Source
var ErrUnsupportedFileExt = fmt.Errorf("unsupported testcase file extension")

Functions

func GetLogger

func GetLogger() zerolog.Logger

func Run

func Run(testcases ...ITestCase) error

run API test with default configs

func SetLogLevel

func SetLogLevel(level string)

func SetLogPretty

func SetLogPretty()

func Step

func Step(name string) *step

Types

type Boomer

type Boomer struct {
	*boomer.Boomer
	// contains filtered or unexported fields
}

func NewStandaloneBoomer

func NewStandaloneBoomer(spawnCount int, spawnRate float64) *Boomer

func (*Boomer) Quit

func (b *Boomer) Quit()

func (*Boomer) Run

func (b *Boomer) Run(testcases ...ITestCase)

func (*Boomer) SetDebug

func (b *Boomer) SetDebug(debug bool) *Boomer

type EnumHTTPMethod

type EnumHTTPMethod string
const (
	GET     EnumHTTPMethod = "GET"
	HEAD    EnumHTTPMethod = "HEAD"
	POST    EnumHTTPMethod = "POST"
	PUT     EnumHTTPMethod = "PUT"
	DELETE  EnumHTTPMethod = "DELETE"
	OPTIONS EnumHTTPMethod = "OPTIONS"
	PATCH   EnumHTTPMethod = "PATCH"
)

type IStep

type IStep interface {
	Name() string
	Type() string
	ToStruct() *TStep
}

interface for all types of steps

type ITestCase

type ITestCase interface {
	ToTestCase() (*TestCase, error)
	ToTCase() (*TCase, error)
}

type ResponseObject

type ResponseObject struct {
	// contains filtered or unexported fields
}

func NewResponseObject

func NewResponseObject(t *testing.T, resp *http.Response) (*ResponseObject, error)

func (*ResponseObject) Extract

func (v *ResponseObject) Extract(extractors map[string]string) map[string]interface{}

func (*ResponseObject) Validate

func (v *ResponseObject) Validate(validators []TValidator, variablesMapping map[string]interface{}) (err error)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(t *testing.T) *Runner

func (*Runner) GetSummary

func (r *Runner) GetSummary() *TestCaseSummary

func (*Runner) Run

func (r *Runner) Run(testcases ...ITestCase) error

func (*Runner) SetDebug

func (r *Runner) SetDebug(debug bool) *Runner

func (*Runner) SetProxyUrl

func (r *Runner) SetProxyUrl(proxyUrl string) *Runner

type StepData

type StepData struct {
	Name           string                 // step name
	Success        bool                   // step execution result
	ResponseLength int64                  // response body length
	ExportVars     map[string]interface{} // extract variables
}

type TCase

type TCase struct {
	Config    TConfig  `json:"config" yaml:"config"`
	TestSteps []*TStep `json:"teststeps" yaml:"teststeps"`
}

used for testcase json loading and dumping

func (*TCase) Dump2JSON

func (tc *TCase) Dump2JSON(path string) error

func (*TCase) Dump2YAML

func (tc *TCase) Dump2YAML(path string) error

func (*TCase) ToTestCase

func (tc *TCase) ToTestCase() (*TestCase, error)

type TConfig

type TConfig struct {
	Name       string                 `json:"name" yaml:"name"`
	Verify     bool                   `json:"verify,omitempty" yaml:"verify,omitempty"`
	BaseURL    string                 `json:"base_url,omitempty" yaml:"base_url,omitempty"`
	Variables  map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"`
	Parameters map[string]interface{} `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	Export     []string               `json:"export,omitempty" yaml:"export,omitempty"`
	Weight     int                    `json:"weight,omitempty" yaml:"weight,omitempty"`
}

type TRequest

type TRequest struct {
	Method         EnumHTTPMethod         `json:"method" yaml:"method"`
	URL            string                 `json:"url" yaml:"url"`
	Params         map[string]interface{} `json:"params,omitempty" yaml:"params,omitempty"`
	Headers        map[string]string      `json:"headers,omitempty" yaml:"headers,omitempty"`
	Cookies        map[string]string      `json:"cookies,omitempty" yaml:"cookies,omitempty"`
	Body           interface{}            `json:"body,omitempty" yaml:"body,omitempty"`
	Timeout        float32                `json:"timeout,omitempty" yaml:"timeout,omitempty"`
	AllowRedirects bool                   `json:"allow_redirects,omitempty" yaml:"allow_redirects,omitempty"`
	Verify         bool                   `json:"verify,omitempty" yaml:"verify,omitempty"`
}

type TStep

type TStep struct {
	Name          string                 `json:"name" yaml:"name"`
	Transaction   string                 `json:"transaction,omitempty" yaml:"transaction,omitempty"`
	Request       *TRequest              `json:"request,omitempty" yaml:"request,omitempty"`
	TestCase      *TestCase              `json:"testcase,omitempty" yaml:"testcase,omitempty"`
	Variables     map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"`
	SetupHooks    []string               `json:"setup_hooks,omitempty" yaml:"setup_hooks,omitempty"`
	TeardownHooks []string               `json:"teardown_hooks,omitempty" yaml:"teardown_hooks,omitempty"`
	Extract       map[string]string      `json:"extract,omitempty" yaml:"extract,omitempty"`
	Validators    []TValidator           `json:"validate,omitempty" yaml:"validate,omitempty"`
	Export        []string               `json:"export,omitempty" yaml:"export,omitempty"`
}

type TValidator

type TValidator struct {
	Check   string      `json:"check,omitempty" yaml:"check,omitempty"` // get value with jmespath
	Assert  string      `json:"assert,omitempty" yaml:"assert,omitempty"`
	Expect  interface{} `json:"expect,omitempty" yaml:"expect,omitempty"`
	Message string      `json:"msg,omitempty" yaml:"msg,omitempty"`
}

type TestCase

type TestCase struct {
	Config    TConfig
	TestSteps []IStep
}

used for testcase runner

func (*TestCase) ToTCase

func (tc *TestCase) ToTCase() (*TCase, error)

func (*TestCase) ToTestCase

func (tc *TestCase) ToTestCase() (*TestCase, error)

type TestCasePath

type TestCasePath struct {
	Path string
}

func (*TestCasePath) ToTCase

func (path *TestCasePath) ToTCase() (*TCase, error)

func (*TestCasePath) ToTestCase

func (path *TestCasePath) ToTestCase() (*TestCase, error)

type TestCaseSummary

type TestCaseSummary struct{}

Directories

Path Synopsis
hrp
cmd
plugin module

Jump to

Keyboard shortcuts

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