mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
refactor: move files
This commit is contained in:
@@ -2,6 +2,7 @@ package hrp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -737,3 +738,38 @@ func runStepMobileUI(s *SessionRunner, step IStep) (stepResult *StepResult, err
|
||||
stepResult.Success = true
|
||||
return stepResult, nil
|
||||
}
|
||||
|
||||
func validateUI(ud *uixt.DriverExt, iValidators []interface{}) (validateResults []*ValidationResult, err error) {
|
||||
for _, iValidator := range iValidators {
|
||||
validator, ok := iValidator.(Validator)
|
||||
if !ok {
|
||||
return nil, errors.New("validator type error")
|
||||
}
|
||||
|
||||
validataResult := &ValidationResult{
|
||||
Validator: validator,
|
||||
CheckResult: "fail",
|
||||
}
|
||||
|
||||
// parse check value
|
||||
if !strings.HasPrefix(validator.Check, "ui_") {
|
||||
validataResult.CheckResult = "skip"
|
||||
log.Warn().Interface("validator", validator).Msg("skip validator")
|
||||
validateResults = append(validateResults, validataResult)
|
||||
continue
|
||||
}
|
||||
|
||||
expected, ok := validator.Expect.(string)
|
||||
if !ok {
|
||||
return nil, errors.New("validator expect should be string")
|
||||
}
|
||||
|
||||
if !ud.DoValidation(validator.Check, validator.Assert, expected, validator.Message) {
|
||||
return validateResults, errors.New("step validation failed")
|
||||
}
|
||||
|
||||
validataResult.CheckResult = "pass"
|
||||
validateResults = append(validateResults, validataResult)
|
||||
}
|
||||
return validateResults, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user