refactor: move hrp/ to root folder

This commit is contained in:
lilong.129
2025-02-06 10:52:08 +08:00
parent 9376692b71
commit 1f063dd6f7
221 changed files with 206 additions and 211 deletions

26
pkg/convert/from_json.go Normal file
View File

@@ -0,0 +1,26 @@
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
}