fix: InvalidCaseError

This commit is contained in:
lilong.129
2024-09-19 11:49:15 +08:00
parent 88fd0181c3
commit 4e191c8fe4

View File

@@ -32,7 +32,7 @@ func (path *TestCasePath) GetTestCase() (*TestCase, error) {
return nil, err return nil, err
} }
if tc.Steps == nil { if tc.Steps == nil {
return nil, errors.Wrap(code.InvalidCaseFormat, return nil, errors.Wrap(code.InvalidCaseError,
"invalid testcase format, missing teststeps!") "invalid testcase format, missing teststeps!")
} }
@@ -171,7 +171,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
} else { } else {
apiMap, ok := step.API.(map[string]interface{}) apiMap, ok := step.API.(map[string]interface{})
if !ok { if !ok {
return nil, errors.Wrap(code.InvalidCaseFormat, return nil, errors.Wrap(code.InvalidCaseError,
fmt.Sprintf("referenced api should be map or path(string), got %v", step.API)) fmt.Sprintf("referenced api should be map or path(string), got %v", step.API))
} }
api := &API{} api := &API{}
@@ -183,7 +183,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
} }
_, ok = step.API.(*API) _, ok = step.API.(*API)
if !ok { if !ok {
return nil, errors.Wrap(code.InvalidCaseFormat, return nil, errors.Wrap(code.InvalidCaseError,
fmt.Sprintf("failed to handle referenced API, got %v", step.TestCase)) fmt.Sprintf("failed to handle referenced API, got %v", step.TestCase))
} }
testCase.TestSteps = append(testCase.TestSteps, &StepAPIWithOptionalArgs{ testCase.TestSteps = append(testCase.TestSteps, &StepAPIWithOptionalArgs{
@@ -207,7 +207,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
} else { } else {
testCaseMap, ok := step.TestCase.(map[string]interface{}) testCaseMap, ok := step.TestCase.(map[string]interface{})
if !ok { if !ok {
return nil, errors.Wrap(code.InvalidCaseFormat, return nil, errors.Wrap(code.InvalidCaseError,
fmt.Sprintf("referenced testcase should be map or path(string), got %v", step.TestCase)) fmt.Sprintf("referenced testcase should be map or path(string), got %v", step.TestCase))
} }
tCase := &TestCase{} tCase := &TestCase{}
@@ -223,7 +223,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
} }
_, ok = step.TestCase.(*TestCase) _, ok = step.TestCase.(*TestCase)
if !ok { if !ok {
return nil, errors.Wrap(code.InvalidCaseFormat, return nil, errors.Wrap(code.InvalidCaseError,
fmt.Sprintf("failed to handle referenced testcase, got %v", step.TestCase)) fmt.Sprintf("failed to handle referenced testcase, got %v", step.TestCase))
} }
testCase.TestSteps = append(testCase.TestSteps, &StepTestCaseWithOptionalArgs{ testCase.TestSteps = append(testCase.TestSteps, &StepTestCaseWithOptionalArgs{
@@ -305,7 +305,7 @@ func convertCompatValidator(Validators []interface{}) (err error) {
validatorMap[strKey] = value validatorMap[strKey] = value
} }
} else { } else {
return errors.Wrap(code.InvalidCaseFormat, return errors.Wrap(code.InvalidCaseError,
fmt.Sprintf("unexpected validator format: %v", iValidator)) fmt.Sprintf("unexpected validator format: %v", iValidator))
} }
@@ -331,7 +331,7 @@ func convertCompatValidator(Validators []interface{}) (err error) {
for assertMethod, iValidatorContent := range validatorMap { for assertMethod, iValidatorContent := range validatorMap {
validatorContent := iValidatorContent.([]interface{}) validatorContent := iValidatorContent.([]interface{})
if len(validatorContent) > 3 { if len(validatorContent) > 3 {
return errors.Wrap(code.InvalidCaseFormat, return errors.Wrap(code.InvalidCaseError,
fmt.Sprintf("unexpected validator format: %v", validatorMap)) fmt.Sprintf("unexpected validator format: %v", validatorMap))
} }
validator.Check = validatorContent[0].(string) validator.Check = validatorContent[0].(string)
@@ -345,7 +345,7 @@ func convertCompatValidator(Validators []interface{}) (err error) {
Validators[i] = validator Validators[i] = validator
continue continue
} }
return errors.Wrap(code.InvalidCaseFormat, return errors.Wrap(code.InvalidCaseError,
fmt.Sprintf("unexpected validator format: %v", validatorMap)) fmt.Sprintf("unexpected validator format: %v", validatorMap))
} }
return nil return nil