mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
Merge pull request #1317 from xucong053/add-empty-project
feat: support create empty project with hrp startproject
This commit is contained in:
@@ -37,4 +37,4 @@ Copyright 2017 debugtalk
|
|||||||
* [hrp startproject](hrp_startproject.md) - create a scaffold project
|
* [hrp startproject](hrp_startproject.md) - create a scaffold project
|
||||||
* [hrp wiki](hrp_wiki.md) - visit https://httprunner.com
|
* [hrp wiki](hrp_wiki.md) - visit https://httprunner.com
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 25-May-2022
|
###### Auto generated by spf13/cobra on 27-May-2022
|
||||||
|
|||||||
@@ -42,4 +42,4 @@ hrp boom [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 25-May-2022
|
###### Auto generated by spf13/cobra on 27-May-2022
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ hrp convert $path... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 25-May-2022
|
###### Auto generated by spf13/cobra on 27-May-2022
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ hrp har2case $har_path... [flags]
|
|||||||
-h, --help help for har2case
|
-h, --help help for har2case
|
||||||
-d, --output-dir string specify output directory, default to the same dir with har file
|
-d, --output-dir string specify output directory, default to the same dir with har file
|
||||||
-p, --profile string specify profile path to override headers and cookies
|
-p, --profile string specify profile path to override headers and cookies
|
||||||
-j, --to-json convert to JSON format (default true)
|
-j, --to-json convert to JSON format (default)
|
||||||
-y, --to-yaml convert to YAML format
|
-y, --to-yaml convert to YAML format
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -24,4 +24,4 @@ hrp har2case $har_path... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 25-May-2022
|
###### Auto generated by spf13/cobra on 27-May-2022
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ hrp pytest $path ... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 25-May-2022
|
###### Auto generated by spf13/cobra on 27-May-2022
|
||||||
|
|||||||
@@ -35,4 +35,4 @@ hrp run $path... [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 25-May-2022
|
###### Auto generated by spf13/cobra on 27-May-2022
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ hrp startproject $project_name [flags]
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
```
|
```
|
||||||
|
--empty generate empty project
|
||||||
-f, --force force to overwrite existing project
|
-f, --force force to overwrite existing project
|
||||||
--go generate hashicorp go plugin
|
--go generate hashicorp go plugin
|
||||||
-h, --help help for startproject
|
-h, --help help for startproject
|
||||||
@@ -20,4 +21,4 @@ hrp startproject $project_name [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 25-May-2022
|
###### Auto generated by spf13/cobra on 27-May-2022
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ hrp wiki [flags]
|
|||||||
|
|
||||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||||
|
|
||||||
###### Auto generated by spf13/cobra on 25-May-2022
|
###### Auto generated by spf13/cobra on 27-May-2022
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-with-go-plugin",
|
"project_name": "demo-with-go-plugin",
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-go-plugin",
|
"project_path": "/Users/xxxxx/go/src/github.com/httprunner/httprunner/examples/demo-with-go-plugin",
|
||||||
"create_time": "2022-05-25T11:14:42.750876+08:00",
|
"create_time": "2022-05-27T11:34:23.903959+08:00",
|
||||||
"hrp_version": "v4.1.0-beta"
|
"hrp_version": "v4.1.0-beta"
|
||||||
}
|
}
|
||||||
@@ -26,8 +26,8 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo3"
|
body: "foo1=$foo1&foo2=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.form.foo1", "bar1"]
|
- eq: ["body.form.foo1", "bar1"]
|
||||||
- eq: ["body.form.foo2", "bar21"]
|
- eq: ["body.form.foo2", "bar21"]
|
||||||
@@ -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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -76,20 +76,20 @@
|
|||||||
"User-Agent": "funplugin/${get_version()}",
|
"User-Agent": "funplugin/${get_version()}",
|
||||||
"Content-Type": "text/plain"
|
"Content-Type": "text/plain"
|
||||||
},
|
},
|
||||||
"data": "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
"body": "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
},
|
},
|
||||||
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -105,32 +105,32 @@
|
|||||||
"User-Agent": "funplugin/${get_version()}",
|
"User-Agent": "funplugin/${get_version()}",
|
||||||
"Content-Type": "application/x-www-form-urlencoded"
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
},
|
},
|
||||||
"data": "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
"body": "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
},
|
},
|
||||||
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "text/plain"
|
Content-Type: "text/plain"
|
||||||
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
body: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
||||||
@@ -56,7 +56,7 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
body: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.form.foo1", "$expect_foo1"]
|
- eq: ["body.form.foo1", "$expect_foo1"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-with-py-plugin",
|
"project_name": "demo-with-py-plugin",
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-with-py-plugin",
|
"project_path": "/Users/xxxxx/go/src/github.com/httprunner/httprunner/examples/demo-with-py-plugin",
|
||||||
"create_time": "2022-05-25T11:14:52.333942+08:00",
|
"create_time": "2022-05-27T11:34:31.852589+08:00",
|
||||||
"hrp_version": "v4.1.0-beta"
|
"hrp_version": "v4.1.0-beta"
|
||||||
}
|
}
|
||||||
@@ -26,8 +26,8 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo3"
|
body: "foo1=$foo1&foo2=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.form.foo1", "bar1"]
|
- eq: ["body.form.foo1", "bar1"]
|
||||||
- eq: ["body.form.foo2", "bar21"]
|
- eq: ["body.form.foo2", "bar21"]
|
||||||
@@ -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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -76,20 +76,20 @@
|
|||||||
"User-Agent": "funplugin/${get_version()}",
|
"User-Agent": "funplugin/${get_version()}",
|
||||||
"Content-Type": "text/plain"
|
"Content-Type": "text/plain"
|
||||||
},
|
},
|
||||||
"data": "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
"body": "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
},
|
},
|
||||||
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -105,32 +105,32 @@
|
|||||||
"User-Agent": "funplugin/${get_version()}",
|
"User-Agent": "funplugin/${get_version()}",
|
||||||
"Content-Type": "application/x-www-form-urlencoded"
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
},
|
},
|
||||||
"data": "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
"body": "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
},
|
},
|
||||||
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "text/plain"
|
Content-Type: "text/plain"
|
||||||
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
body: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
||||||
@@ -56,7 +56,7 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
body: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.form.foo1", "$expect_foo1"]
|
- eq: ["body.form.foo1", "$expect_foo1"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"project_name": "demo-without-plugin",
|
"project_name": "demo-without-plugin",
|
||||||
"project_path": "/Users/debugtalk/MyProjects/HttpRunner-dev/httprunner/examples/demo-without-plugin",
|
"project_path": "/Users/xxxxx/go/src/github.com/httprunner/httprunner/examples/demo-without-plugin",
|
||||||
"create_time": "2022-05-25T11:14:53.862348+08:00",
|
"create_time": "2022-05-27T11:34:32.548637+08:00",
|
||||||
"hrp_version": "v4.1.0-beta"
|
"hrp_version": "v4.1.0-beta"
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,9 @@ var scaffoldCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pluginType scaffold.PluginType
|
var pluginType scaffold.PluginType
|
||||||
if ignorePlugin {
|
if empty {
|
||||||
|
pluginType = scaffold.Empty
|
||||||
|
} else if ignorePlugin {
|
||||||
pluginType = scaffold.Ignore
|
pluginType = scaffold.Ignore
|
||||||
} else if genGoPlugin {
|
} else if genGoPlugin {
|
||||||
pluginType = scaffold.Go
|
pluginType = scaffold.Go
|
||||||
@@ -43,6 +45,7 @@ var scaffoldCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
empty bool
|
||||||
ignorePlugin bool
|
ignorePlugin bool
|
||||||
genPythonPlugin bool
|
genPythonPlugin bool
|
||||||
genGoPlugin bool
|
genGoPlugin bool
|
||||||
@@ -55,4 +58,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")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,10 @@ func TestGenDemoExamples(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal()
|
t.Fatal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dir = "../../../examples/empty-demo-without-plugin"
|
||||||
|
err = CreateScaffold(dir, Empty, true)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
type PluginType string
|
type PluginType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Empty PluginType = "empty"
|
||||||
Ignore PluginType = "ignore"
|
Ignore PluginType = "ignore"
|
||||||
Py PluginType = "py"
|
Py PluginType = "py"
|
||||||
Go PluginType = "go"
|
Go PluginType = "go"
|
||||||
@@ -127,8 +128,17 @@ func CreateScaffold(projectName string, pluginType PluginType, force bool) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// create demo testcases
|
// create project testcases
|
||||||
if pluginType == Ignore {
|
if pluginType == Empty {
|
||||||
|
// create empty project
|
||||||
|
err := CopyFile("templates/testcases/demo_empty_request.json",
|
||||||
|
filepath.Join(projectName, "testcases", "requests.json"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
} 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 {
|
||||||
@@ -138,6 +148,7 @@ func CreateScaffold(projectName string, pluginType PluginType, force bool) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create project with funplugin
|
||||||
err = CopyFile("templates/testcases/demo_with_funplugin.json",
|
err = CopyFile("templates/testcases/demo_with_funplugin.json",
|
||||||
filepath.Join(projectName, "testcases", "demo.json"))
|
filepath.Join(projectName, "testcases", "demo.json"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -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,13 @@
|
|||||||
|
config:
|
||||||
|
name: "request methods testcase: empty testcase"
|
||||||
|
variables:
|
||||||
|
verify: False
|
||||||
|
|
||||||
|
teststeps:
|
||||||
|
- name:
|
||||||
|
variables:
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: "https://"
|
||||||
|
validate:
|
||||||
|
- eq: ["status_code", 200]
|
||||||
@@ -8,16 +8,14 @@
|
|||||||
"app_version": "2.8.6"
|
"app_version": "2.8.6"
|
||||||
},
|
},
|
||||||
"base_url": "https://postman-echo.com",
|
"base_url": "https://postman-echo.com",
|
||||||
"herader": [
|
"headers": {
|
||||||
{
|
"Accept": "*/*",
|
||||||
"Accept": "*/*",
|
"Accept-Encoding": "gzip, deflate, br",
|
||||||
"Accept-Encoding": "gzip, deflate, br",
|
"Cache-Control": "no-cache",
|
||||||
"Cache-Control": "no-cache",
|
"Connection": "keep-alive",
|
||||||
"Connection": "keep-alive",
|
"Host": "postman-echo.com",
|
||||||
"Host": "postman-echo.com",
|
"User-Agent": "PostmanRuntime/7.28.4"
|
||||||
"User-Agent": "PostmanRuntime/7.28.4"
|
},
|
||||||
}
|
|
||||||
],
|
|
||||||
"verify": false,
|
"verify": false,
|
||||||
"export": [
|
"export": [
|
||||||
"session_token"
|
"session_token"
|
||||||
@@ -48,16 +46,16 @@
|
|||||||
},
|
},
|
||||||
"validate": [
|
"validate": [
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "status_code",
|
||||||
"status_code",
|
"assert": "equal",
|
||||||
200
|
"expect": 200,
|
||||||
]
|
"msg": "check status_code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"eq": [
|
"check": "body.headers.postman-token",
|
||||||
"body.headers.postman-token",
|
"assert": "equal",
|
||||||
"ea19464c-ddd4-4724-abe9-5e2b254c2723"
|
"expect": "ea19464c-ddd4-4724-abe9-5e2b254c2723",
|
||||||
]
|
"msg": "check body.headers.postman-token"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo3"
|
body: "foo1=$foo1&foo2=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.form.foo1", "bar1"]
|
- eq: ["body.form.foo1", "bar1"]
|
||||||
- eq: ["body.form.foo2", "bar21"]
|
- eq: ["body.form.foo2", "bar21"]
|
||||||
@@ -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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -76,20 +76,20 @@
|
|||||||
"User-Agent": "funplugin/${get_version()}",
|
"User-Agent": "funplugin/${get_version()}",
|
||||||
"Content-Type": "text/plain"
|
"Content-Type": "text/plain"
|
||||||
},
|
},
|
||||||
"data": "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
"body": "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
},
|
},
|
||||||
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -105,32 +105,32 @@
|
|||||||
"User-Agent": "funplugin/${get_version()}",
|
"User-Agent": "funplugin/${get_version()}",
|
||||||
"Content-Type": "application/x-www-form-urlencoded"
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
},
|
},
|
||||||
"data": "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
"body": "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
},
|
},
|
||||||
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "text/plain"
|
Content-Type: "text/plain"
|
||||||
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
body: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar32."]
|
||||||
@@ -56,7 +56,7 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: funplugin/${get_version()}
|
User-Agent: funplugin/${get_version()}
|
||||||
Content-Type: "application/x-www-form-urlencoded"
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
body: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.form.foo1", "$expect_foo1"]
|
- eq: ["body.form.foo1", "$expect_foo1"]
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const (
|
|||||||
goPluginFile = "debugtalk.so" // built from go plugin
|
goPluginFile = "debugtalk.so" // built from go plugin
|
||||||
hashicorpGoPluginFile = "debugtalk.bin" // built from hashicorp go plugin
|
hashicorpGoPluginFile = "debugtalk.bin" // built from hashicorp go plugin
|
||||||
hashicorpPyPluginFile = "debugtalk.py" // used for hashicorp python plugin
|
hashicorpPyPluginFile = "debugtalk.py" // used for hashicorp python plugin
|
||||||
|
projectInfoFile = "proj.json" // used for ensuring root project
|
||||||
)
|
)
|
||||||
|
|
||||||
func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, pluginDir string, err error) {
|
func initPlugin(path string, logOn bool) (plugin funplugin.IPlugin, pluginDir string, err error) {
|
||||||
@@ -118,9 +119,15 @@ func GetProjectRootDirPath(path string) (rootDir string, err error) {
|
|||||||
rootDir = filepath.Dir(pluginPath)
|
rootDir = filepath.Dir(pluginPath)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// fix: no debugtalk file in project but having proj.json created by startpeoject
|
||||||
|
projPath, err := locateFile(path, projectInfoFile)
|
||||||
|
if err == nil {
|
||||||
|
rootDir = filepath.Dir(projPath)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// failed to locate project root dir
|
// failed to locate project root dir
|
||||||
// maybe project plugin debugtalk.xx is not exist
|
// maybe project plugin debugtalk.xx and proj.json are not exist
|
||||||
// use current dir instead
|
// use current dir instead
|
||||||
return os.Getwd()
|
return os.Getwd()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user