mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 07:57:27 +08:00
fix: check case validation
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
package convert
|
package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp"
|
"github.com/httprunner/httprunner/v4/hrp"
|
||||||
@@ -16,8 +14,9 @@ func LoadJSONCase(path string) (*hrp.TCase, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "load json file failed")
|
return nil, errors.Wrap(err, "load json file failed")
|
||||||
}
|
}
|
||||||
if reflect.ValueOf(*caseJSON).IsZero() {
|
|
||||||
return nil, errors.New("invalid json file")
|
if caseJSON.TestSteps == nil {
|
||||||
|
return nil, errors.New("invalid json case file, missing teststeps")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = caseJSON.MakeCompat()
|
err = caseJSON.MakeCompat()
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ func loadCasePostman(path string) (*CasePostman, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "load postman file failed")
|
return nil, errors.Wrap(err, "load postman file failed")
|
||||||
}
|
}
|
||||||
if reflect.ValueOf(*casePostman).IsZero() {
|
if casePostman.Items == nil {
|
||||||
return nil, errors.New("invalid postman file")
|
return nil, errors.New("invalid postman case file, missing items")
|
||||||
}
|
}
|
||||||
|
|
||||||
return casePostman, nil
|
return casePostman, nil
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package convert
|
package convert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"github.com/go-openapi/spec"
|
"github.com/go-openapi/spec"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
@@ -17,8 +15,8 @@ func LoadSwaggerCase(path string) (*hrp.TCase, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "load swagger file failed")
|
return nil, errors.Wrap(err, "load swagger file failed")
|
||||||
}
|
}
|
||||||
if reflect.ValueOf(*caseSwagger).IsZero() {
|
if caseSwagger.Definitions == nil {
|
||||||
return nil, errors.New("invalid swagger file")
|
return nil, errors.New("invalid swagger case file, missing definitions")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: convert swagger to TCase
|
// TODO: convert swagger to TCase
|
||||||
|
|||||||
Reference in New Issue
Block a user