mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-01 05:49:40 +08:00
feat: run tsetcase by path
This commit is contained in:
27
convert.go
27
convert.go
@@ -3,6 +3,7 @@ package httpboomer
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"path/filepath"
|
||||
@@ -124,3 +125,29 @@ func convertTestCase(tc *TCase) (*TestCase, error) {
|
||||
}
|
||||
return testCase, nil
|
||||
}
|
||||
|
||||
var ErrUnsupportedFileExt = fmt.Errorf("unsupported testcase file extension")
|
||||
|
||||
func loadTestFile(path *TestCasePath) (*TestCase, error) {
|
||||
var tc *TCase
|
||||
var err error
|
||||
|
||||
casePath := path.string
|
||||
ext := filepath.Ext(casePath)
|
||||
switch ext {
|
||||
case ".json":
|
||||
tc, err = loadFromJSON(casePath)
|
||||
case ".yaml", ".yml":
|
||||
tc, err = loadFromYAML(casePath)
|
||||
default:
|
||||
err = ErrUnsupportedFileExt
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
testcase, err := convertTestCase(tc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return testcase, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user