mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-26 01:51:29 +08:00
change: rename LoadFile to LoadFileObject
This commit is contained in:
@@ -70,8 +70,8 @@ func LoadTestCases(tests ...ITestCase) ([]*TestCase, error) {
|
||||
return testCases, nil
|
||||
}
|
||||
|
||||
// LoadFile loads file content with file extension and assigns to structObj
|
||||
func LoadFile(path string, structObj interface{}) (err error) {
|
||||
// LoadFileObject loads file content with file extension and assigns to structObj
|
||||
func LoadFileObject(path string, structObj interface{}) (err error) {
|
||||
log.Info().Str("path", path).Msg("load file")
|
||||
file, err := builtin.ReadFile(path)
|
||||
if err != nil {
|
||||
|
||||
@@ -53,11 +53,11 @@ func TestLoadTestCases(t *testing.T) {
|
||||
func TestLoadCase(t *testing.T) {
|
||||
tcJSON := &TestCase{}
|
||||
tcYAML := &TestCase{}
|
||||
err := LoadFile(demoTestCaseWithPluginJSONPath, tcJSON)
|
||||
err := LoadFileObject(demoTestCaseWithPluginJSONPath, tcJSON)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
err = LoadFile(demoTestCaseWithPluginYAMLPath, tcYAML)
|
||||
err = LoadFileObject(demoTestCaseWithPluginYAMLPath, tcYAML)
|
||||
if !assert.NoError(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ func LoadHARCase(path string) (*hrp.TestCase, error) {
|
||||
|
||||
func loadCaseHAR(path string) (*CaseHar, error) {
|
||||
caseHAR := new(CaseHar)
|
||||
err := hrp.LoadFile(path, caseHAR)
|
||||
err := hrp.LoadFileObject(path, caseHAR)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load har file failed")
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func LoadJSONCase(path string) (*hrp.TestCase, error) {
|
||||
log.Info().Str("path", path).Msg("load json case file")
|
||||
caseJSON := new(hrp.TestCase)
|
||||
err := hrp.LoadFile(path, caseJSON)
|
||||
err := hrp.LoadFileObject(path, caseJSON)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load json file failed")
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func LoadPostmanCase(path string) (*hrp.TestCase, error) {
|
||||
|
||||
func loadCasePostman(path string) (*CasePostman, error) {
|
||||
casePostman := new(CasePostman)
|
||||
err := hrp.LoadFile(path, casePostman)
|
||||
err := hrp.LoadFileObject(path, casePostman)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load postman file failed")
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func LoadSwaggerCase(path string) (*hrp.TestCase, error) {
|
||||
// load swagger file
|
||||
caseSwagger := new(spec.Swagger)
|
||||
err := hrp.LoadFile(path, caseSwagger)
|
||||
err := hrp.LoadFileObject(path, caseSwagger)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "load swagger file failed")
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func LoadYAMLCase(path string) (*hrp.TestCase, error) {
|
||||
// load yaml case file
|
||||
caseJSON := new(hrp.TestCase)
|
||||
err := hrp.LoadFile(path, caseJSON)
|
||||
err := hrp.LoadFileObject(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 := hrp.LoadFile(path, profile)
|
||||
err := hrp.LoadFileObject(path, profile)
|
||||
if err != nil {
|
||||
log.Warn().Str("path", path).
|
||||
Msg("failed to load profile, ignore!")
|
||||
|
||||
@@ -44,7 +44,7 @@ func (path *APIPath) GetPath() string {
|
||||
func (path *APIPath) ToAPI() (*API, error) {
|
||||
api := &API{}
|
||||
apiPath := path.GetPath()
|
||||
err := LoadFile(apiPath, api)
|
||||
err := LoadFileObject(apiPath, api)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ type TestCasePath string
|
||||
func (path *TestCasePath) GetTestCase() (*TestCase, error) {
|
||||
tc := &TestCase{}
|
||||
casePath := string(*path)
|
||||
err := LoadFile(casePath, tc)
|
||||
err := LoadFileObject(casePath, tc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func (tc *TestCase) loadISteps() (*TestCase, error) {
|
||||
dotEnvPath := filepath.Join(projectRootDir, ".env")
|
||||
if builtin.IsFilePathExists(dotEnvPath) {
|
||||
envVars := make(map[string]string)
|
||||
err = LoadFile(dotEnvPath, envVars)
|
||||
err = LoadFileObject(dotEnvPath, envVars)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to load .env file")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user