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