feat: support api layer and global headers for testcase

This commit is contained in:
xucong053
2022-03-15 12:39:41 +08:00
parent 3b9e6cd736
commit af6c433069
37 changed files with 907 additions and 135 deletions

View File

@@ -12,8 +12,8 @@ import (
)
var (
demoTestCaseJSONPath = "../../examples/demo.json"
demoTestCaseYAMLPath = "../../examples/demo.yaml"
demoTestCaseJSONPath hrp.TestCasePath = "../../examples/demo.json"
demoTestCaseYAMLPath hrp.TestCasePath = "../../examples/demo.yaml"
)
func buildHashicorpPlugin() {
@@ -33,11 +33,11 @@ func removeHashicorpPlugin() {
func TestGenDemoTestCase(t *testing.T) {
tCase, _ := demoTestCase.ToTCase()
err := builtin.Dump2JSON(tCase, demoTestCaseJSONPath)
err := builtin.Dump2JSON(tCase, demoTestCaseJSONPath.ToString())
if err != nil {
t.Fail()
}
err = builtin.Dump2YAML(tCase, demoTestCaseYAMLPath)
err = builtin.Dump2YAML(tCase, demoTestCaseYAMLPath.ToString())
if err != nil {
t.Fail()
}
@@ -58,8 +58,7 @@ func TestJsonDemo(t *testing.T) {
buildHashicorpPlugin()
defer removeHashicorpPlugin()
testCase := &hrp.TestCasePath{Path: demoTestCaseJSONPath}
err := hrp.NewRunner(nil).Run(testCase) // hrp.Run(testCase)
err := hrp.NewRunner(nil).Run(&demoTestCaseJSONPath) // hrp.Run(testCase)
if err != nil {
t.Fail()
}
@@ -69,8 +68,7 @@ func TestYamlDemo(t *testing.T) {
buildHashicorpPlugin()
defer removeHashicorpPlugin()
testCase := &hrp.TestCasePath{Path: demoTestCaseYAMLPath}
err := hrp.NewRunner(nil).Run(testCase) // hrp.Run(testCase)
err := hrp.NewRunner(nil).Run(&demoTestCaseYAMLPath) // hrp.Run(testCase)
if err != nil {
t.Fail()
}