mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
feat: create empty project by using hrp startproject #1280
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"project_name": "demo-with-go-plugin",
|
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-go-plugin",
|
|
||||||
"create_time": "2022-05-25T11:14:42.750876+08:00",
|
|
||||||
"hrp_version": "v4.1.0-beta"
|
|
||||||
}
|
|
||||||
@@ -28,6 +28,15 @@ teststeps:
|
|||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo3"
|
data: "foo1=$foo1&foo2=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.form.foo1", "bar1"]
|
assert: equal
|
||||||
- eq: ["body.form.foo2", "bar21"]
|
expect: 200
|
||||||
|
msg: check status_code
|
||||||
|
- check: body.form.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: bar1
|
||||||
|
msg: check body.form.foo1
|
||||||
|
- check: body.form.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.form.foo2
|
||||||
@@ -38,28 +38,28 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.foo1",
|
||||||
"body.args.foo1",
|
"assert": "equal",
|
||||||
"debugtalk"
|
"expect": "debugtalk",
|
||||||
]
|
"msg": "check body.args.foo1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.sum_v",
|
||||||
"body.args.sum_v",
|
"assert": "equal",
|
||||||
"3"
|
"expect": "3",
|
||||||
]
|
"msg": "check body.args.sum_v"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.foo2",
|
||||||
"body.args.foo2",
|
"assert": "equal",
|
||||||
"bar21"
|
"expect": "bar21",
|
||||||
]
|
"msg": "check body.args.foo2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -80,16 +80,16 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.data",
|
||||||
"body.data",
|
"assert": "equal",
|
||||||
"This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."
|
"expect": "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32.",
|
||||||
]
|
"msg": "check body.data"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -109,28 +109,28 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo1",
|
||||||
"body.form.foo1",
|
"assert": "equal",
|
||||||
"$expect_foo1"
|
"expect": "$expect_foo1",
|
||||||
]
|
"msg": "check body.form.foo1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo2",
|
||||||
"body.form.foo2",
|
"assert": "equal",
|
||||||
"bar23"
|
"expect": "bar23",
|
||||||
]
|
"msg": "check body.form.foo2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo3",
|
||||||
"body.form.foo3",
|
"assert": "equal",
|
||||||
"bar21"
|
"expect": "bar21",
|
||||||
]
|
"msg": "check body.form.foo3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,22 @@ teststeps:
|
|||||||
extract:
|
extract:
|
||||||
foo3: "body.args.foo2"
|
foo3: "body.args.foo2"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.args.foo1", "debugtalk"]
|
assert: equal
|
||||||
- eq: ["body.args.sum_v", "3"]
|
expect: 200
|
||||||
- eq: ["body.args.foo2", "bar21"]
|
msg: check status_code
|
||||||
|
- check: body.args.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: debugtalk
|
||||||
|
msg: check body.args.foo1
|
||||||
|
- check: body.args.sum_v
|
||||||
|
assert: equal
|
||||||
|
expect: "3"
|
||||||
|
msg: check body.args.sum_v
|
||||||
|
- check: body.args.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.args.foo2
|
||||||
-
|
-
|
||||||
name: post raw text
|
name: post raw text
|
||||||
variables:
|
variables:
|
||||||
@@ -44,8 +56,14 @@ teststeps:
|
|||||||
Content-Type: "text/plain"
|
Content-Type: "text/plain"
|
||||||
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
assert: equal
|
||||||
|
expect: 200
|
||||||
|
msg: check status_code
|
||||||
|
- check: body.data
|
||||||
|
assert: equal
|
||||||
|
expect: "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."
|
||||||
|
msg: check body.data
|
||||||
-
|
-
|
||||||
name: post form data
|
name: post form data
|
||||||
variables:
|
variables:
|
||||||
@@ -58,7 +76,19 @@ teststeps:
|
|||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.form.foo1", "$expect_foo1"]
|
assert: equal
|
||||||
- eq: ["body.form.foo2", "bar23"]
|
expect: 200
|
||||||
- eq: ["body.form.foo3", "bar21"]
|
msg: check status_code
|
||||||
|
- check: body.form.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: $expect_foo1
|
||||||
|
msg: check body.form.foo1
|
||||||
|
- check: body.form.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar23
|
||||||
|
msg: check body.form.foo2
|
||||||
|
- check: body.form.foo3
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.form.foo3
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"project_name": "demo-with-py-plugin",
|
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-py-plugin",
|
|
||||||
"create_time": "2022-05-25T11:14:52.333942+08:00",
|
|
||||||
"hrp_version": "v4.1.0-beta"
|
|
||||||
}
|
|
||||||
@@ -28,6 +28,15 @@ teststeps:
|
|||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo3"
|
data: "foo1=$foo1&foo2=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.form.foo1", "bar1"]
|
assert: equal
|
||||||
- eq: ["body.form.foo2", "bar21"]
|
expect: 200
|
||||||
|
msg: check status_code
|
||||||
|
- check: body.form.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: bar1
|
||||||
|
msg: check body.form.foo1
|
||||||
|
- check: body.form.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.form.foo2
|
||||||
@@ -38,28 +38,28 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.foo1",
|
||||||
"body.args.foo1",
|
"assert": "equal",
|
||||||
"debugtalk"
|
"expect": "debugtalk",
|
||||||
]
|
"msg": "check body.args.foo1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.sum_v",
|
||||||
"body.args.sum_v",
|
"assert": "equal",
|
||||||
"3"
|
"expect": "3",
|
||||||
]
|
"msg": "check body.args.sum_v"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.foo2",
|
||||||
"body.args.foo2",
|
"assert": "equal",
|
||||||
"bar21"
|
"expect": "bar21",
|
||||||
]
|
"msg": "check body.args.foo2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -80,16 +80,16 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.data",
|
||||||
"body.data",
|
"assert": "equal",
|
||||||
"This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."
|
"expect": "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32.",
|
||||||
]
|
"msg": "check body.data"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -109,28 +109,28 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo1",
|
||||||
"body.form.foo1",
|
"assert": "equal",
|
||||||
"$expect_foo1"
|
"expect": "$expect_foo1",
|
||||||
]
|
"msg": "check body.form.foo1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo2",
|
||||||
"body.form.foo2",
|
"assert": "equal",
|
||||||
"bar23"
|
"expect": "bar23",
|
||||||
]
|
"msg": "check body.form.foo2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo3",
|
||||||
"body.form.foo3",
|
"assert": "equal",
|
||||||
"bar21"
|
"expect": "bar21",
|
||||||
]
|
"msg": "check body.form.foo3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,22 @@ teststeps:
|
|||||||
extract:
|
extract:
|
||||||
foo3: "body.args.foo2"
|
foo3: "body.args.foo2"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.args.foo1", "debugtalk"]
|
assert: equal
|
||||||
- eq: ["body.args.sum_v", "3"]
|
expect: 200
|
||||||
- eq: ["body.args.foo2", "bar21"]
|
msg: check status_code
|
||||||
|
- check: body.args.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: debugtalk
|
||||||
|
msg: check body.args.foo1
|
||||||
|
- check: body.args.sum_v
|
||||||
|
assert: equal
|
||||||
|
expect: "3"
|
||||||
|
msg: check body.args.sum_v
|
||||||
|
- check: body.args.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.args.foo2
|
||||||
-
|
-
|
||||||
name: post raw text
|
name: post raw text
|
||||||
variables:
|
variables:
|
||||||
@@ -44,8 +56,14 @@ teststeps:
|
|||||||
Content-Type: "text/plain"
|
Content-Type: "text/plain"
|
||||||
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
assert: equal
|
||||||
|
expect: 200
|
||||||
|
msg: check status_code
|
||||||
|
- check: body.data
|
||||||
|
assert: equal
|
||||||
|
expect: "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."
|
||||||
|
msg: check body.data
|
||||||
-
|
-
|
||||||
name: post form data
|
name: post form data
|
||||||
variables:
|
variables:
|
||||||
@@ -58,7 +76,19 @@ teststeps:
|
|||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.form.foo1", "$expect_foo1"]
|
assert: equal
|
||||||
- eq: ["body.form.foo2", "bar23"]
|
expect: 200
|
||||||
- eq: ["body.form.foo3", "bar21"]
|
msg: check status_code
|
||||||
|
- check: body.form.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: $expect_foo1
|
||||||
|
msg: check body.form.foo1
|
||||||
|
- check: body.form.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar23
|
||||||
|
msg: check body.form.foo2
|
||||||
|
- check: body.form.foo3
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.form.foo3
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"project_name": "demo-without-plugin",
|
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-without-plugin",
|
|
||||||
"create_time": "2022-05-25T11:14:53.862348+08:00",
|
|
||||||
"hrp_version": "v4.1.0-beta"
|
|
||||||
}
|
|
||||||
+3
-1
@@ -32,7 +32,7 @@ var scaffoldCmd = &cobra.Command{
|
|||||||
pluginType = scaffold.Py // default
|
pluginType = scaffold.Py // default
|
||||||
}
|
}
|
||||||
|
|
||||||
err := scaffold.CreateScaffold(args[0], pluginType, force)
|
err := scaffold.CreateScaffold(args[0], pluginType, empty, force)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("create scaffold project failed")
|
log.Error().Err(err).Msg("create scaffold project failed")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -43,6 +43,7 @@ var scaffoldCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
empty bool
|
||||||
ignorePlugin bool
|
ignorePlugin bool
|
||||||
genPythonPlugin bool
|
genPythonPlugin bool
|
||||||
genGoPlugin bool
|
genGoPlugin bool
|
||||||
@@ -55,4 +56,5 @@ func init() {
|
|||||||
scaffoldCmd.Flags().BoolVar(&genPythonPlugin, "py", true, "generate hashicorp python plugin")
|
scaffoldCmd.Flags().BoolVar(&genPythonPlugin, "py", true, "generate hashicorp python plugin")
|
||||||
scaffoldCmd.Flags().BoolVar(&genGoPlugin, "go", false, "generate hashicorp go plugin")
|
scaffoldCmd.Flags().BoolVar(&genGoPlugin, "go", false, "generate hashicorp go plugin")
|
||||||
scaffoldCmd.Flags().BoolVar(&ignorePlugin, "ignore-plugin", false, "ignore function plugin")
|
scaffoldCmd.Flags().BoolVar(&ignorePlugin, "ignore-plugin", false, "ignore function plugin")
|
||||||
|
scaffoldCmd.Flags().BoolVar(&empty, "empty", false, "generate empty project")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,19 +6,37 @@ import (
|
|||||||
|
|
||||||
func TestGenDemoExamples(t *testing.T) {
|
func TestGenDemoExamples(t *testing.T) {
|
||||||
dir := "../../../examples/demo-with-go-plugin"
|
dir := "../../../examples/demo-with-go-plugin"
|
||||||
err := CreateScaffold(dir, Go, true)
|
err := CreateScaffold(dir, Go, false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = "../../../examples/demo-with-py-plugin"
|
dir = "../../../examples/demo-with-py-plugin"
|
||||||
err = CreateScaffold(dir, Py, true)
|
err = CreateScaffold(dir, Py, false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = "../../../examples/demo-without-plugin"
|
dir = "../../../examples/demo-without-plugin"
|
||||||
err = CreateScaffold(dir, Ignore, true)
|
err = CreateScaffold(dir, Ignore, false, true)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal()
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = "../../../examples/empty-demo-without-plugin"
|
||||||
|
err = CreateScaffold(dir, Ignore, true, true)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal()
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = "../../../examples/empty-demo-with-py-plugin"
|
||||||
|
err = CreateScaffold(dir, Py, true, true)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal()
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = "../../../examples/empty-demo-with-go-plugin"
|
||||||
|
err = CreateScaffold(dir, Go, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ func CopyFile(templateFile, targetFile string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateScaffold(projectName string, pluginType PluginType, force bool) error {
|
func CreateScaffold(projectName string, pluginType PluginType, empty bool, force bool) error {
|
||||||
// report event
|
// report event
|
||||||
sdk.SendEvent(sdk.EventTracking{
|
sdk.SendEvent(sdk.EventTracking{
|
||||||
Category: "Scaffold",
|
Category: "Scaffold",
|
||||||
@@ -127,38 +127,49 @@ func CreateScaffold(projectName string, pluginType PluginType, force bool) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// create demo testcases
|
// create project testcases
|
||||||
if pluginType == Ignore {
|
if empty {
|
||||||
|
// create empty project
|
||||||
|
err := CopyFile("templates/testcases/demo_empty_request.json",
|
||||||
|
filepath.Join(projectName, "testcases", "requests.json"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else if pluginType == Ignore {
|
||||||
|
// create project without funplugin
|
||||||
err := CopyFile("templates/testcases/demo_without_funplugin.json",
|
err := CopyFile("templates/testcases/demo_without_funplugin.json",
|
||||||
filepath.Join(projectName, "testcases", "requests.json"))
|
filepath.Join(projectName, "testcases", "requests.json"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// create project with funplugin
|
||||||
|
err = CopyFile("templates/testcases/demo_with_funplugin.json",
|
||||||
|
filepath.Join(projectName, "testcases", "demo.json"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = CopyFile("templates/testcases/demo_requests.json",
|
||||||
|
filepath.Join(projectName, "testcases", "requests.json"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = CopyFile("templates/testcases/demo_requests.yml",
|
||||||
|
filepath.Join(projectName, "testcases", "requests.yml"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = CopyFile("templates/testcases/demo_ref_testcase.yml",
|
||||||
|
filepath.Join(projectName, "testcases", "ref_testcase.yml"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if pluginType == Ignore {
|
||||||
log.Info().Msg("skip creating function plugin")
|
log.Info().Msg("skip creating function plugin")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = CopyFile("templates/testcases/demo_with_funplugin.json",
|
|
||||||
filepath.Join(projectName, "testcases", "demo.json"))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = CopyFile("templates/testcases/demo_requests.json",
|
|
||||||
filepath.Join(projectName, "testcases", "requests.json"))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = CopyFile("templates/testcases/demo_requests.yml",
|
|
||||||
filepath.Join(projectName, "testcases", "requests.yml"))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = CopyFile("templates/testcases/demo_ref_testcase.yml",
|
|
||||||
filepath.Join(projectName, "testcases", "ref_testcase.yml"))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// create debugtalk function plugin
|
// create debugtalk function plugin
|
||||||
switch pluginType {
|
switch pluginType {
|
||||||
case Py:
|
case Py:
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"name": "request methods testcase: empty testcase",
|
||||||
|
"variables": null,
|
||||||
|
"verify": false
|
||||||
|
},
|
||||||
|
"teststeps": [
|
||||||
|
{
|
||||||
|
"name": "",
|
||||||
|
"variables": null,
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://"
|
||||||
|
},
|
||||||
|
"validate": [
|
||||||
|
{
|
||||||
|
"check": "status_code",
|
||||||
|
"assert": "equal",
|
||||||
|
"expect": 200,
|
||||||
|
"msg": "check status_code"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
config:
|
||||||
|
name: "request methods testcase: empty testcase"
|
||||||
|
variables:
|
||||||
|
verify: False
|
||||||
|
|
||||||
|
teststeps:
|
||||||
|
- name:
|
||||||
|
variables:
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "https://"
|
||||||
|
validate:
|
||||||
|
- check: status_code
|
||||||
|
assert: equal
|
||||||
|
expect: 200
|
||||||
|
msg: check status_code
|
||||||
@@ -28,6 +28,15 @@ teststeps:
|
|||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo3"
|
data: "foo1=$foo1&foo2=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.form.foo1", "bar1"]
|
assert: equal
|
||||||
- eq: ["body.form.foo2", "bar21"]
|
expect: 200
|
||||||
|
msg: check status_code
|
||||||
|
- check: body.form.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: bar1
|
||||||
|
msg: check body.form.foo1
|
||||||
|
- check: body.form.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.form.foo2
|
||||||
@@ -38,28 +38,28 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.foo1",
|
||||||
"body.args.foo1",
|
"assert": "equal",
|
||||||
"debugtalk"
|
"expect": "debugtalk",
|
||||||
]
|
"msg": "check body.args.foo1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.sum_v",
|
||||||
"body.args.sum_v",
|
"assert": "equal",
|
||||||
"3"
|
"expect": "3",
|
||||||
]
|
"msg": "check body.args.sum_v"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.args.foo2",
|
||||||
"body.args.foo2",
|
"assert": "equal",
|
||||||
"bar21"
|
"expect": "bar21",
|
||||||
]
|
"msg": "check body.args.foo2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -80,16 +80,16 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.data",
|
||||||
"body.data",
|
"assert": "equal",
|
||||||
"This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."
|
"expect": "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32.",
|
||||||
]
|
"msg": "check body.data"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -109,28 +109,28 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo1",
|
||||||
"body.form.foo1",
|
"assert": "equal",
|
||||||
"$expect_foo1"
|
"expect": "$expect_foo1",
|
||||||
]
|
"msg": "check body.form.foo1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo2",
|
||||||
"body.form.foo2",
|
"assert": "equal",
|
||||||
"bar23"
|
"expect": "bar23",
|
||||||
]
|
"msg": "check body.form.foo2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.form.foo3",
|
||||||
"body.form.foo3",
|
"assert": "equal",
|
||||||
"bar21"
|
"expect": "bar21",
|
||||||
]
|
"msg": "check body.form.foo3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,22 @@ teststeps:
|
|||||||
extract:
|
extract:
|
||||||
foo3: "body.args.foo2"
|
foo3: "body.args.foo2"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.args.foo1", "debugtalk"]
|
assert: equal
|
||||||
- eq: ["body.args.sum_v", "3"]
|
expect: 200
|
||||||
- eq: ["body.args.foo2", "bar21"]
|
msg: check status_code
|
||||||
|
- check: body.args.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: debugtalk
|
||||||
|
msg: check body.args.foo1
|
||||||
|
- check: body.args.sum_v
|
||||||
|
assert: equal
|
||||||
|
expect: "3"
|
||||||
|
msg: check body.args.sum_v
|
||||||
|
- check: body.args.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.args.foo2
|
||||||
-
|
-
|
||||||
name: post raw text
|
name: post raw text
|
||||||
variables:
|
variables:
|
||||||
@@ -44,8 +56,14 @@ teststeps:
|
|||||||
Content-Type: "text/plain"
|
Content-Type: "text/plain"
|
||||||
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
assert: equal
|
||||||
|
expect: 200
|
||||||
|
msg: check status_code
|
||||||
|
- check: body.data
|
||||||
|
assert: equal
|
||||||
|
expect: "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."
|
||||||
|
msg: check body.data
|
||||||
-
|
-
|
||||||
name: post form data
|
name: post form data
|
||||||
variables:
|
variables:
|
||||||
@@ -58,7 +76,19 @@ teststeps:
|
|||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- check: status_code
|
||||||
- eq: ["body.form.foo1", "$expect_foo1"]
|
assert: equal
|
||||||
- eq: ["body.form.foo2", "bar23"]
|
expect: 200
|
||||||
- eq: ["body.form.foo3", "bar21"]
|
msg: check status_code
|
||||||
|
- check: body.form.foo1
|
||||||
|
assert: equal
|
||||||
|
expect: $expect_foo1
|
||||||
|
msg: check body.form.foo1
|
||||||
|
- check: body.form.foo2
|
||||||
|
assert: equal
|
||||||
|
expect: bar23
|
||||||
|
msg: check body.form.foo2
|
||||||
|
- check: body.form.foo3
|
||||||
|
assert: equal
|
||||||
|
expect: bar21
|
||||||
|
msg: check body.form.foo3
|
||||||
|
|||||||
Reference in New Issue
Block a user