mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
refactor: move LoadFile to hrp/loader
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||
)
|
||||
|
||||
@@ -371,7 +370,7 @@ func LoadHARCase(path string) (*hrp.TestCase, error) {
|
||||
|
||||
func loadCaseHAR(path string) (*CaseHar, error) {
|
||||
caseHAR := new(CaseHar)
|
||||
err := builtin.LoadFile(path, caseHAR)
|
||||
err := hrp.LoadFile(path, caseHAR)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load har file failed")
|
||||
}
|
||||
|
||||
@@ -5,13 +5,12 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
)
|
||||
|
||||
func LoadJSONCase(path string) (*hrp.TestCase, error) {
|
||||
log.Info().Str("path", path).Msg("load json case file")
|
||||
caseJSON := new(hrp.TestCase)
|
||||
err := builtin.LoadFile(path, caseJSON)
|
||||
err := hrp.LoadFile(path, caseJSON)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load json file failed")
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||
)
|
||||
|
||||
@@ -125,7 +124,7 @@ func LoadPostmanCase(path string) (*hrp.TestCase, error) {
|
||||
|
||||
func loadCasePostman(path string) (*CasePostman, error) {
|
||||
casePostman := new(CasePostman)
|
||||
err := builtin.LoadFile(path, casePostman)
|
||||
err := hrp.LoadFile(path, casePostman)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load postman file failed")
|
||||
}
|
||||
|
||||
@@ -5,13 +5,12 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
)
|
||||
|
||||
func LoadSwaggerCase(path string) (*hrp.TestCase, error) {
|
||||
// load swagger file
|
||||
caseSwagger := new(spec.Swagger)
|
||||
err := builtin.LoadFile(path, caseSwagger)
|
||||
err := hrp.LoadFile(path, caseSwagger)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load swagger file failed")
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
)
|
||||
|
||||
func LoadYAMLCase(path string) (*hrp.TestCase, error) {
|
||||
// load yaml case file
|
||||
caseJSON := new(hrp.TestCase)
|
||||
err := builtin.LoadFile(path, caseJSON)
|
||||
err := hrp.LoadFile(path, caseJSON)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load yaml file failed")
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ func (c *TCaseConverter) genOutputPath(suffix string) string {
|
||||
func (c *TCaseConverter) overrideWithProfile(path string) error {
|
||||
log.Info().Str("path", path).Msg("load profile")
|
||||
profile := new(Profile)
|
||||
err := builtin.LoadFile(path, profile)
|
||||
err := hrp.LoadFile(path, profile)
|
||||
if err != nil {
|
||||
log.Warn().Str("path", path).
|
||||
Msg("failed to load profile, ignore!")
|
||||
|
||||
Reference in New Issue
Block a user