mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 17:29:56 +08:00
29 lines
575 B
Go
29 lines
575 B
Go
package convert
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/httprunner/httprunner/v4/hrp"
|
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
|
)
|
|
|
|
func LoadYAMLCase(path string) (*hrp.TCase, error) {
|
|
// load yaml case file
|
|
caseJSON := new(hrp.TCase)
|
|
err := builtin.LoadFile(path, caseJSON)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "load yaml file failed")
|
|
}
|
|
if reflect.ValueOf(*caseJSON).IsZero() {
|
|
return nil, errors.New("invalid yaml file")
|
|
}
|
|
|
|
err = caseJSON.MakeCompat()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return caseJSON, nil
|
|
}
|