refactor: rename convert files

This commit is contained in:
debugtalk
2022-06-27 16:39:23 +08:00
parent ccdd60dba1
commit e816f8cb5f
10 changed files with 498 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package convert
import (
"reflect"
"github.com/pkg/errors"
"github.com/httprunner/httprunner/v4/hrp"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
)
func LoadJSONCase(path string) (*hrp.TCase, error) {
// load json case file
caseJSON := new(hrp.TCase)
err := builtin.LoadFile(path, caseJSON)
if err != nil {
return nil, errors.Wrap(err, "load json file failed")
}
if reflect.ValueOf(*caseJSON).IsZero() {
return nil, errors.New("invalid json file")
}
// convert json case to TCase
err = caseJSON.MakeCompat()
if err != nil {
return nil, err
}
return caseJSON, nil
}