mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
change: rename variables
This commit is contained in:
+9
-9
@@ -5,21 +5,21 @@ type StepRequestExtraction struct {
|
|||||||
*TStep
|
*TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *StepRequestExtraction) WithJmesPath(jmesPath string, varName string) *StepRequestExtraction {
|
func (step *StepRequestExtraction) WithJmesPath(jmesPath string, varName string) *StepRequestExtraction {
|
||||||
req.TStep.Extract[varName] = jmesPath
|
step.TStep.Extract[varName] = jmesPath
|
||||||
return req
|
return step
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *StepRequestExtraction) Validate() *StepRequestValidation {
|
func (step *StepRequestExtraction) Validate() *StepRequestValidation {
|
||||||
return &StepRequestValidation{
|
return &StepRequestValidation{
|
||||||
TStep: req.TStep,
|
TStep: step.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *StepRequestExtraction) ToStruct() *TStep {
|
func (step *StepRequestExtraction) ToStruct() *TStep {
|
||||||
return req.TStep
|
return step.TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *StepRequestExtraction) Run() error {
|
func (step *StepRequestExtraction) Run() error {
|
||||||
return req.TStep.Run()
|
return step.TStep.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
+65
-65
@@ -14,64 +14,64 @@ type Request struct {
|
|||||||
*TStep
|
*TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) WithVariables(variables Variables) *Request {
|
func (r *Request) WithVariables(variables Variables) *Request {
|
||||||
req.TStep.Variables = variables
|
r.TStep.Variables = variables
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) GET(url string) *RequestWithOptionalArgs {
|
func (r *Request) GET(url string) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Method = GET
|
r.TStep.Request.Method = GET
|
||||||
req.TStep.Request.URL = url
|
r.TStep.Request.URL = url
|
||||||
return &RequestWithOptionalArgs{
|
return &RequestWithOptionalArgs{
|
||||||
TStep: req.TStep,
|
TStep: r.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) HEAD(url string) *RequestWithOptionalArgs {
|
func (r *Request) HEAD(url string) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Method = HEAD
|
r.TStep.Request.Method = HEAD
|
||||||
req.TStep.Request.URL = url
|
r.TStep.Request.URL = url
|
||||||
return &RequestWithOptionalArgs{
|
return &RequestWithOptionalArgs{
|
||||||
TStep: req.TStep,
|
TStep: r.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) POST(url string) *RequestWithOptionalArgs {
|
func (r *Request) POST(url string) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Method = POST
|
r.TStep.Request.Method = POST
|
||||||
req.TStep.Request.URL = url
|
r.TStep.Request.URL = url
|
||||||
return &RequestWithOptionalArgs{
|
return &RequestWithOptionalArgs{
|
||||||
TStep: req.TStep,
|
TStep: r.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) PUT(url string) *RequestWithOptionalArgs {
|
func (r *Request) PUT(url string) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Method = PUT
|
r.TStep.Request.Method = PUT
|
||||||
req.TStep.Request.URL = url
|
r.TStep.Request.URL = url
|
||||||
return &RequestWithOptionalArgs{
|
return &RequestWithOptionalArgs{
|
||||||
TStep: req.TStep,
|
TStep: r.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) DELETE(url string) *RequestWithOptionalArgs {
|
func (r *Request) DELETE(url string) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Method = DELETE
|
r.TStep.Request.Method = DELETE
|
||||||
req.TStep.Request.URL = url
|
r.TStep.Request.URL = url
|
||||||
return &RequestWithOptionalArgs{
|
return &RequestWithOptionalArgs{
|
||||||
TStep: req.TStep,
|
TStep: r.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) OPTIONS(url string) *RequestWithOptionalArgs {
|
func (r *Request) OPTIONS(url string) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Method = OPTIONS
|
r.TStep.Request.Method = OPTIONS
|
||||||
req.TStep.Request.URL = url
|
r.TStep.Request.URL = url
|
||||||
return &RequestWithOptionalArgs{
|
return &RequestWithOptionalArgs{
|
||||||
TStep: req.TStep,
|
TStep: r.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) PATCH(url string) *RequestWithOptionalArgs {
|
func (r *Request) PATCH(url string) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Method = PATCH
|
r.TStep.Request.Method = PATCH
|
||||||
req.TStep.Request.URL = url
|
r.TStep.Request.URL = url
|
||||||
return &RequestWithOptionalArgs{
|
return &RequestWithOptionalArgs{
|
||||||
TStep: req.TStep,
|
TStep: r.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,66 +80,66 @@ type RequestWithOptionalArgs struct {
|
|||||||
*TStep
|
*TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) SetVerify(verify bool) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) SetVerify(verify bool) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Verify = verify
|
r.TStep.Request.Verify = verify
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) SetTimeout(timeout float32) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) SetTimeout(timeout float32) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Timeout = timeout
|
r.TStep.Request.Timeout = timeout
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) SetProxies(proxies map[string]string) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) SetProxies(proxies map[string]string) *RequestWithOptionalArgs {
|
||||||
// TODO
|
// TODO
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) SetAllowRedirects(allowRedirects bool) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) SetAllowRedirects(allowRedirects bool) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.AllowRedirects = allowRedirects
|
r.TStep.Request.AllowRedirects = allowRedirects
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) SetAuth(auth map[string]string) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) SetAuth(auth map[string]string) *RequestWithOptionalArgs {
|
||||||
// TODO
|
// TODO
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) WithParams(params Params) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) WithParams(params Params) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Params = params
|
r.TStep.Request.Params = params
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) WithHeaders(headers Headers) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) WithHeaders(headers Headers) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Headers = headers
|
r.TStep.Request.Headers = headers
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) WithCookies(cookies Cookies) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) WithCookies(cookies Cookies) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Cookies = cookies
|
r.TStep.Request.Cookies = cookies
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) WithData(data interface{}) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) WithData(data interface{}) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.Data = data
|
r.TStep.Request.Data = data
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) WithJSON(json interface{}) *RequestWithOptionalArgs {
|
func (r *RequestWithOptionalArgs) WithJSON(json interface{}) *RequestWithOptionalArgs {
|
||||||
req.TStep.Request.JSON = json
|
r.TStep.Request.JSON = json
|
||||||
return req
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) Validate() *StepRequestValidation {
|
func (r *RequestWithOptionalArgs) Validate() *StepRequestValidation {
|
||||||
return &StepRequestValidation{
|
return &StepRequestValidation{
|
||||||
TStep: req.TStep,
|
TStep: r.TStep,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) ToStruct() *TStep {
|
func (r *RequestWithOptionalArgs) ToStruct() *TStep {
|
||||||
return req.TStep
|
return r.TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *RequestWithOptionalArgs) Run() error {
|
func (r *RequestWithOptionalArgs) Run() error {
|
||||||
return req.TStep.Run()
|
return r.TStep.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -5,21 +5,21 @@ type StepRequestValidation struct {
|
|||||||
*TStep
|
*TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *StepRequestValidation) AssertEqual(jmesPath string, expected interface{}, msg string) *StepRequestValidation {
|
func (step *StepRequestValidation) AssertEqual(jmesPath string, expected interface{}, msg string) *StepRequestValidation {
|
||||||
validator := TValidator{
|
validator := TValidator{
|
||||||
Check: jmesPath,
|
Check: jmesPath,
|
||||||
Comparator: "equals",
|
Comparator: "equals",
|
||||||
Expect: expected,
|
Expect: expected,
|
||||||
Message: msg,
|
Message: msg,
|
||||||
}
|
}
|
||||||
req.TStep.Validators = append(req.TStep.Validators, validator)
|
step.TStep.Validators = append(step.TStep.Validators, validator)
|
||||||
return req
|
return step
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *StepRequestValidation) ToStruct() *TStep {
|
func (step *StepRequestValidation) ToStruct() *TStep {
|
||||||
return req.TStep
|
return step.TStep
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *StepRequestValidation) Run() error {
|
func (step *StepRequestValidation) Run() error {
|
||||||
return req.TStep.Run()
|
return step.TStep.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user