mqplan

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2017 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExpectStatus = "status"
	ExpectBody   = "body"
)
View Source
const (
	MeqaInit = "meqa_init"
)

Variables

This section is empty.

Functions

func ArrayParamsResolveWithHistory

func ArrayParamsResolveWithHistory(paramArray []interface{}, h *TestHistory)

func GeneratePathTestSuite

func GeneratePathTestSuite(operations mqswag.NodeList, plan *TestPlan)

All the operations have the same path. We generate one test suite, with the tests of ascending weight and priority among the operations

func GenerateTestsForObject

func GenerateTestsForObject(create *mqswag.DAGNode, obj *mqswag.DAGNode, plan *TestPlan) error

GenerateTestsForObject for the obj that we traversed to from create. Add the test suites generated to plan.

func GetBaseURL

func GetBaseURL(swagger *mqswag.Swagger) string

func GetLastPathElement

func GetLastPathElement(name string) string

Given a path name, retrieve the last entry that is not a path param.

func GetLastPathParam

func GetLastPathParam(name string) string

If the last entry on path is a parameter, return it. Otherwise return ""

func GetOperationByMethod

func GetOperationByMethod(item *spec.PathItem, method string) *spec.Operation

func MapParamsResolveWithHistory

func MapParamsResolveWithHistory(paramMap map[string]interface{}, h *TestHistory)

func OperationMatches

func OperationMatches(node *mqswag.DAGNode, method string) bool

func ParamsAdd

func ParamsAdd(dst []spec.Parameter, src []spec.Parameter) []spec.Parameter

ParamsAdd adds the parameters from src to dst if the param doesn't already exist on dst.

func RandomTime

func RandomTime(t time.Time, r time.Duration) time.Time

RandomTime generate a random time in the range of [t - r, t).

func StringParamsResolveWithHistory

func StringParamsResolveWithHistory(str string, h *TestHistory) interface{}

func WriteComment

func WriteComment(comment string, f *os.File)

Types

type Comparison

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

Post: old - nil, new - the new object we create. Put, patch: old - the old object, new - the new one. Get: old - the old object, new - the one we get from the server. Delete: old - the existing object, new - nil.

func (*Comparison) GetMapByOp

func (comp *Comparison) GetMapByOp(op string) map[string]interface{}

func (*Comparison) SetForOp

func (comp *Comparison) SetForOp(op string, key string, value interface{}) *Comparison

type PathWeight

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

type PathWeightList

type PathWeightList []PathWeight

func (PathWeightList) Len

func (n PathWeightList) Len() int

func (PathWeightList) Less

func (n PathWeightList) Less(i, j int) bool

func (PathWeightList) Swap

func (n PathWeightList) Swap(i, j int)

type Test

type Test struct {
	Name       string                 `yaml:"name,omitempty"`
	Path       string                 `yaml:"path,omitempty"`
	Method     string                 `yaml:"method,omitempty"`
	Ref        string                 `yaml:"ref,omitempty"`
	Expect     map[string]interface{} `yaml:"expect,omitempty"`
	Strict     bool                   `yaml:"strict,omitempty"`
	TestParams `yaml:",inline,omitempty" json:",inline,omitempty"`
	// contains filtered or unexported fields
}

Test represents a test object in the DSL. Extra care needs to be taken to copy the Test before running it, because running it would change the parameter maps.

func CreateTestFromOp

func CreateTestFromOp(opNode *mqswag.DAGNode, testId int) *Test

func (*Test) AddBasicComparison

func (t *Test) AddBasicComparison(tag *mqswag.MeqaTag, paramSpec *spec.Parameter, data interface{})

func (*Test) AddObjectComparison

func (t *Test) AddObjectComparison(tag *mqswag.MeqaTag, obj map[string]interface{}, schema *spec.Schema)

func (*Test) CompareGetResult

func (t *Test) CompareGetResult(className string, associations map[string]map[string]interface{}, resultArray []interface{}) error

func (*Test) CopyParent

func (t *Test) CopyParent(parentTest *Test)

func (*Test) Duplicate

func (t *Test) Duplicate() *Test

func (*Test) GenerateParameter

func (t *Test) GenerateParameter(paramSpec *spec.Parameter, db *mqswag.DB) (interface{}, error)

GenerateParameter generates paramter value based on the spec.

func (*Test) GenerateSchema

func (t *Test) GenerateSchema(name string, parentTag *mqswag.MeqaTag, schema *spec.Schema, db *mqswag.DB, level int) (interface{}, error)

The parentTag passed in is what the higher level thinks this schema object should be.

func (*Test) GetParam

func (t *Test) GetParam(path []string) interface{}

func (*Test) Init

func (t *Test) Init(suite *TestSuite)

func (*Test) ProcessOneComparison

func (t *Test) ProcessOneComparison(className string, method string, comp *Comparison,
	associations map[string]map[string]interface{}, collection map[string][]interface{}) error

ProcessOneComparison processes one comparison object.

func (*Test) ProcessResult

func (t *Test) ProcessResult(resp *resty.Response) error

ProcessResult decodes the response from the server into a result array

func (*Test) ResolveHistoryParameters

func (t *Test) ResolveHistoryParameters(h *TestHistory)

func (*Test) ResolveParameters

func (t *Test) ResolveParameters(tc *TestSuite) error

ResolveParameters fullfills the parameters for the specified request using the in-mem DB. The resolved parameters will be added to test.Parameters map.

func (*Test) Run

func (t *Test) Run(tc *TestSuite) error

Run runs the test. Returns the test result.

func (*Test) SetRequestParameters

func (t *Test) SetRequestParameters(req *resty.Request) string

SetRequestParameters sets the parameters. Returns the new request path.

type TestHistory

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

TestHistory records the execution result of all the tests

var History TestHistory

func (*TestHistory) Append

func (h *TestHistory) Append(t *Test)

func (*TestHistory) GetTest

func (h *TestHistory) GetTest(name string) *Test

GetTest gets a test by its name

type TestParams

type TestParams struct {
	QueryParams  map[string]interface{} `yaml:"queryParams,omitempty"`
	FormParams   map[string]interface{} `yaml:"formParams,omitempty"`
	PathParams   map[string]interface{} `yaml:"pathParams,omitempty"`
	HeaderParams map[string]interface{} `yaml:"headerParams,omitempty"`
	BodyParams   interface{}            `yaml:"bodyParams,omitempty"`
}

func (*TestParams) Add

func (dst *TestParams) Add(src *TestParams)

Add the parameters from src. If there is a conflict the dst original value will be kept.

func (*TestParams) Copy

func (dst *TestParams) Copy(src *TestParams)

Copy the parameters from src. If there is a conflict dst will be overwritten.

type TestPlan

type TestPlan struct {
	SuiteMap  map[string](*TestSuite)
	SuiteList [](*TestSuite)

	// global parameters
	TestParams `yaml:",inline,omitempty" json:",inline,omitempty"`
	Strict     bool

	// Authentication
	Username string
	Password string
	ApiToken string
	// contains filtered or unexported fields
}

Represents all the test suites in the DSL.

var Current TestPlan

The current global TestPlan

func GeneratePathTestPlan

func GeneratePathTestPlan(swagger *mqswag.Swagger, dag *mqswag.DAG) (*TestPlan, error)

Go through all the paths in swagger, and generate the tests for all the operations under the path.

func GenerateSimpleTestPlan

func GenerateSimpleTestPlan(swagger *mqswag.Swagger, dag *mqswag.DAG) (*TestPlan, error)

Go through all the paths in swagger, and generate the tests for all the operations under the path.

func GenerateTestPlan

func GenerateTestPlan(swagger *mqswag.Swagger, dag *mqswag.DAG) (*TestPlan, error)

func (*TestPlan) Add

func (plan *TestPlan) Add(testSuite *TestSuite) error

Add a new TestSuite, returns whether the Case is successfully added.

func (*TestPlan) AddFromString

func (plan *TestPlan) AddFromString(data string) error

func (*TestPlan) DumpToFile

func (plan *TestPlan) DumpToFile(path string) error

func (*TestPlan) Init

func (plan *TestPlan) Init(swagger *mqswag.Swagger, db *mqswag.DB)

func (*TestPlan) InitFromFile

func (plan *TestPlan) InitFromFile(path string, db *mqswag.DB) error

func (*TestPlan) Run

func (plan *TestPlan) Run(name string, parentTest *Test) error

Run a named TestSuite in the test plan.

func (*TestPlan) WriteResultToFile

func (plan *TestPlan) WriteResultToFile(path string) error

type TestSuite

type TestSuite struct {
	Tests []*Test
	Name  string

	// test suite parameters
	TestParams `yaml:",inline,omitempty" json:",inline,omitempty"`
	Strict     bool

	// Authentication
	Username string
	Password string
	ApiToken string
	// contains filtered or unexported fields
}

func CreateTestSuite

func CreateTestSuite(name string, tests []*Test, plan *TestPlan) *TestSuite

Jump to

Keyboard shortcuts

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