From 4e191c8fe456c8a7297268bf8f7c2777b2f572c6 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Thu, 19 Sep 2024 11:49:15 +0800 Subject: [PATCH] fix: InvalidCaseError --- hrp/testcase.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hrp/testcase.go b/hrp/testcase.go index 42dae8fc..a45d9e4e 100644 --- a/hrp/testcase.go +++ b/hrp/testcase.go @@ -32,7 +32,7 @@ func (path *TestCasePath) GetTestCase() (*TestCase, error) { return nil, err } if tc.Steps == nil { - return nil, errors.Wrap(code.InvalidCaseFormat, + return nil, errors.Wrap(code.InvalidCaseError, "invalid testcase format, missing teststeps!") } @@ -171,7 +171,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) { } else { apiMap, ok := step.API.(map[string]interface{}) 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)) } api := &API{} @@ -183,7 +183,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) { } _, ok = step.API.(*API) 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)) } testCase.TestSteps = append(testCase.TestSteps, &StepAPIWithOptionalArgs{ @@ -207,7 +207,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) { } else { testCaseMap, ok := step.TestCase.(map[string]interface{}) 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)) } tCase := &TestCase{} @@ -223,7 +223,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) { } _, ok = step.TestCase.(*TestCase) 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)) } testCase.TestSteps = append(testCase.TestSteps, &StepTestCaseWithOptionalArgs{ @@ -305,7 +305,7 @@ func convertCompatValidator(Validators []interface{}) (err error) { validatorMap[strKey] = value } } else { - return errors.Wrap(code.InvalidCaseFormat, + return errors.Wrap(code.InvalidCaseError, fmt.Sprintf("unexpected validator format: %v", iValidator)) } @@ -331,7 +331,7 @@ func convertCompatValidator(Validators []interface{}) (err error) { for assertMethod, iValidatorContent := range validatorMap { validatorContent := iValidatorContent.([]interface{}) if len(validatorContent) > 3 { - return errors.Wrap(code.InvalidCaseFormat, + return errors.Wrap(code.InvalidCaseError, fmt.Sprintf("unexpected validator format: %v", validatorMap)) } validator.Check = validatorContent[0].(string) @@ -345,7 +345,7 @@ func convertCompatValidator(Validators []interface{}) (err error) { Validators[i] = validator continue } - return errors.Wrap(code.InvalidCaseFormat, + return errors.Wrap(code.InvalidCaseError, fmt.Sprintf("unexpected validator format: %v", validatorMap)) } return nil