Documentation ¶
Index ¶
- Constants
- func ArrayParamsResolveWithHistory(paramArray []interface{}, h *TestHistory)
- func GeneratePathTestSuite(operations mqswag.NodeList, plan *TestPlan)
- func GenerateTestsForObject(create *mqswag.DAGNode, obj *mqswag.DAGNode, plan *TestPlan) error
- func GetBaseURL(swagger *mqswag.Swagger) string
- func GetLastPathElement(name string) string
- func GetLastPathParam(name string) string
- func GetOperationByMethod(item *spec.PathItem, method string) *spec.Operation
- func MapParamsResolveWithHistory(paramMap map[string]interface{}, h *TestHistory)
- func OperationMatches(node *mqswag.DAGNode, method string) bool
- func ParamsAdd(dst []spec.Parameter, src []spec.Parameter) []spec.Parameter
- func RandomTime(t time.Time, r time.Duration) time.Time
- func StringParamsResolveWithHistory(str string, h *TestHistory) interface{}
- func WriteComment(comment string, f *os.File)
- type Comparison
- type PathWeight
- type PathWeightList
- type Test
- func (t *Test) AddBasicComparison(tag *mqswag.MeqaTag, paramSpec *spec.Parameter, data interface{})
- func (t *Test) AddObjectComparison(tag *mqswag.MeqaTag, obj map[string]interface{}, schema *spec.Schema)
- func (t *Test) CompareGetResult(className string, associations map[string]map[string]interface{}, ...) error
- func (t *Test) CopyParent(parentTest *Test)
- func (t *Test) Duplicate() *Test
- func (t *Test) GenerateParameter(paramSpec *spec.Parameter, db *mqswag.DB) (interface{}, error)
- func (t *Test) GenerateSchema(name string, parentTag *mqswag.MeqaTag, schema *spec.Schema, db *mqswag.DB, ...) (interface{}, error)
- func (t *Test) GetParam(path []string) interface{}
- func (t *Test) Init(suite *TestSuite)
- func (t *Test) ProcessOneComparison(className string, method string, comp *Comparison, ...) error
- func (t *Test) ProcessResult(resp *resty.Response) error
- func (t *Test) ResolveHistoryParameters(h *TestHistory)
- func (t *Test) ResolveParameters(tc *TestSuite) error
- func (t *Test) Run(tc *TestSuite) error
- func (t *Test) SetRequestParameters(req *resty.Request) string
- type TestHistory
- type TestParams
- type TestPlan
- func (plan *TestPlan) Add(testSuite *TestSuite) error
- func (plan *TestPlan) AddFromString(data string) error
- func (plan *TestPlan) DumpToFile(path string) error
- func (plan *TestPlan) Init(swagger *mqswag.Swagger, db *mqswag.DB)
- func (plan *TestPlan) InitFromFile(path string, db *mqswag.DB) error
- func (plan *TestPlan) Run(name string, parentTest *Test) error
- func (plan *TestPlan) WriteResultToFile(path string) error
- type TestSuite
Constants ¶
const ( ExpectStatus = "status" ExpectBody = "body" )
const (
MeqaInit = "meqa_init"
)
Variables ¶
This section is empty.
Functions ¶
func ArrayParamsResolveWithHistory ¶
func ArrayParamsResolveWithHistory(paramArray []interface{}, h *TestHistory)
func GeneratePathTestSuite ¶
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 ¶
GenerateTestsForObject for the obj that we traversed to from create. Add the test suites generated to plan.
func GetBaseURL ¶
func GetLastPathElement ¶
Given a path name, retrieve the last entry that is not a path param.
func GetLastPathParam ¶
If the last entry on path is a parameter, return it. Otherwise return ""
func GetOperationByMethod ¶
func MapParamsResolveWithHistory ¶
func MapParamsResolveWithHistory(paramMap map[string]interface{}, h *TestHistory)
func ParamsAdd ¶
ParamsAdd adds the parameters from src to dst if the param doesn't already exist on dst.
func RandomTime ¶
RandomTime generate a random time in the range of [t - r, t).
func StringParamsResolveWithHistory ¶
func StringParamsResolveWithHistory(str string, h *TestHistory) interface{}
func WriteComment ¶
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 (*Test) AddBasicComparison ¶
func (*Test) AddObjectComparison ¶
func (*Test) CompareGetResult ¶
func (*Test) CopyParent ¶
func (*Test) GenerateParameter ¶
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) 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 ¶
ProcessResult decodes the response from the server into a result array
func (*Test) ResolveHistoryParameters ¶
func (t *Test) ResolveHistoryParameters(h *TestHistory)
func (*Test) ResolveParameters ¶
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) SetRequestParameters ¶
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 ¶
Go through all the paths in swagger, and generate the tests for all the operations under the path.
func GenerateSimpleTestPlan ¶
Go through all the paths in swagger, and generate the tests for all the operations under the path.