mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-01 22:09:35 +08:00
refactor: NewStep
This commit is contained in:
18
validate.go
18
validate.go
@@ -4,27 +4,27 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// implements IStep interface
|
||||
type stepRequestValidation struct {
|
||||
// StepRequestValidation implements IStep interface.
|
||||
type StepRequestValidation struct {
|
||||
step *TStep
|
||||
}
|
||||
|
||||
func (s *stepRequestValidation) Name() string {
|
||||
func (s *StepRequestValidation) Name() string {
|
||||
if s.step.Name != "" {
|
||||
return s.step.Name
|
||||
}
|
||||
return fmt.Sprintf("%s %s", s.step.Request.Method, s.step.Request.URL)
|
||||
}
|
||||
|
||||
func (s *stepRequestValidation) Type() string {
|
||||
func (s *StepRequestValidation) Type() string {
|
||||
return fmt.Sprintf("request-%v", s.step.Request.Method)
|
||||
}
|
||||
|
||||
func (s *stepRequestValidation) ToStruct() *TStep {
|
||||
func (s *StepRequestValidation) ToStruct() *TStep {
|
||||
return s.step
|
||||
}
|
||||
|
||||
func (s *stepRequestValidation) AssertEqual(jmesPath string, expected interface{}, msg string) *stepRequestValidation {
|
||||
func (s *StepRequestValidation) AssertEqual(jmesPath string, expected interface{}, msg string) *StepRequestValidation {
|
||||
v := Validator{
|
||||
Check: jmesPath,
|
||||
Assert: "equals",
|
||||
@@ -35,7 +35,7 @@ func (s *stepRequestValidation) AssertEqual(jmesPath string, expected interface{
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *stepRequestValidation) AssertStartsWith(jmesPath string, expected interface{}, msg string) *stepRequestValidation {
|
||||
func (s *StepRequestValidation) AssertStartsWith(jmesPath string, expected interface{}, msg string) *StepRequestValidation {
|
||||
v := Validator{
|
||||
Check: jmesPath,
|
||||
Assert: "startswith",
|
||||
@@ -46,7 +46,7 @@ func (s *stepRequestValidation) AssertStartsWith(jmesPath string, expected inter
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *stepRequestValidation) AssertEndsWith(jmesPath string, expected interface{}, msg string) *stepRequestValidation {
|
||||
func (s *StepRequestValidation) AssertEndsWith(jmesPath string, expected interface{}, msg string) *StepRequestValidation {
|
||||
v := Validator{
|
||||
Check: jmesPath,
|
||||
Assert: "endswith",
|
||||
@@ -57,7 +57,7 @@ func (s *stepRequestValidation) AssertEndsWith(jmesPath string, expected interfa
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *stepRequestValidation) AssertLengthEqual(jmesPath string, expected interface{}, msg string) *stepRequestValidation {
|
||||
func (s *StepRequestValidation) AssertLengthEqual(jmesPath string, expected interface{}, msg string) *StepRequestValidation {
|
||||
v := Validator{
|
||||
Check: jmesPath,
|
||||
Assert: "length_equals",
|
||||
|
||||
Reference in New Issue
Block a user