mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-07 06:03:13 +08:00
27 lines
606 B
Go
27 lines
606 B
Go
package convert
|
|
|
|
import (
|
|
hrp "github.com/httprunner/httprunner/v5"
|
|
"github.com/pkg/errors"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
func LoadJSONCase(path string) (*hrp.TestCaseDef, error) {
|
|
log.Info().Str("path", path).Msg("load json case file")
|
|
caseJSON := new(hrp.TestCaseDef)
|
|
err := hrp.LoadFileObject(path, caseJSON)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "load json file failed")
|
|
}
|
|
|
|
if caseJSON.Steps == nil {
|
|
return nil, errors.New("invalid json case file, missing teststeps")
|
|
}
|
|
|
|
err = hrp.ConvertCaseCompatibility(caseJSON)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return caseJSON, nil
|
|
}
|