fix: unittest

This commit is contained in:
xucong053
2022-05-27 16:40:17 +08:00
parent 4bb7d8e619
commit 08ff6fe5f5
47 changed files with 87 additions and 1366 deletions

View File

@@ -46,12 +46,12 @@ func GetVersion() string {
}
func main() {
fungo.Register("GetVersion", GetVersion)
fungo.Register("SumInts", SumInts)
fungo.Register("SumTwoInt", SumTwoInt)
fungo.Register("SumTwoInt", SumTwoInt)
fungo.Register("Sum", Sum)
fungo.Register("SetupHookExample", SetupHookExample)
fungo.Register("TeardownHookExample", TeardownHookExample)
fungo.Register("get_version", GetVersion)
fungo.Register("sum_ints", SumInts)
fungo.Register("sum_two_int", SumTwoInt)
fungo.Register("sum_two", SumTwoInt)
fungo.Register("sum", Sum)
fungo.Register("setup_hook_example", SetupHookExample)
fungo.Register("teardown_hook_example", TeardownHookExample)
fungo.Serve()
}

View File

@@ -2,4 +2,4 @@ module plugin
go 1.16
require github.com/httprunner/funplugin v0.4.6 // indirect
require github.com/httprunner/funplugin v0.4.7 // indirect

View File

@@ -58,8 +58,8 @@ github.com/hashicorp/go-plugin v1.4.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v
github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/httprunner/funplugin v0.4.6 h1:wwpjzo3G9a5BCXBkHs845w4ifKaCtVa/yQjREQjQOgo=
github.com/httprunner/funplugin v0.4.6/go.mod h1:vPyeJIfbpGe0epZZtAV0wCn16gLY9+imSw/zfxq0Lcc=
github.com/httprunner/funplugin v0.4.7 h1:bmk84BL8oPGE/rgxCuHgPcwJtBnwDzm/ocmFY/cKcos=
github.com/httprunner/funplugin v0.4.7/go.mod h1:vPyeJIfbpGe0epZZtAV0wCn16gLY9+imSw/zfxq0Lcc=
github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=

View File

@@ -1,6 +1,6 @@
{
"project_name": "demo-with-go-plugin",
"project_path": "/Users/xxxxx/go/src/github.com/httprunner/httprunner/examples/demo-with-go-plugin",
"create_time": "2022-05-27T11:34:23.903959+08:00",
"create_time": "2022-05-28T02:00:18.084185+08:00",
"hrp_version": "v4.1.0-beta"
}

View File

@@ -3,9 +3,9 @@
"name": "demo with complex mechanisms",
"base_url": "https://postman-echo.com",
"variables": {
"a": "${Sum(10, 2.3)}",
"a": "${sum(10, 2.3)}",
"b": 3.45,
"n": "${SumInts(1, 2, 2)}",
"n": "${sum_ints(1, 2, 2)}",
"varFoo1": "${gen_random_string($n)}",
"varFoo2": "${max($a, $b)}"
}
@@ -38,10 +38,10 @@
"varFoo2": "${max($a, $b)}"
},
"setup_hooks": [
"${SetupHookExample($name)}"
"${setup_hook_example($name)}"
],
"teardown_hooks": [
"${TeardownHookExample($name)}"
"${teardown_hook_example($name)}"
],
"extract": {
"varFoo1": "body.args.foo1"

View File

@@ -24,7 +24,7 @@ teststeps:
method: POST
url: /post
headers:
User-Agent: funplugin/${GetVersion()}
User-Agent: funplugin/${get_version()}
Content-Type: "application/x-www-form-urlencoded"
body: "foo1=$foo1&foo2=$foo3"
validate:

View File

@@ -19,7 +19,7 @@
"variables": {
"foo1": "${ENV(USERNAME)}",
"foo2": "bar21",
"sum_v": "${SumTwoInt(1, 2)}"
"sum_v": "${sum_two_int(1, 2)}"
},
"request": {
"method": "GET",
@@ -30,7 +30,7 @@
"sum_v": "$sum_v"
},
"headers": {
"User-Agent": "funplugin/${GetVersion()}"
"User-Agent": "funplugin/${get_version()}"
}
},
"extract": {
@@ -73,7 +73,7 @@
"method": "POST",
"url": "/post",
"headers": {
"User-Agent": "funplugin/${GetVersion()}",
"User-Agent": "funplugin/${get_version()}",
"Content-Type": "text/plain"
},
"body": "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
@@ -102,7 +102,7 @@
"method": "POST",
"url": "/post",
"headers": {
"User-Agent": "funplugin/${GetVersion()}",
"User-Agent": "funplugin/${get_version()}",
"Content-Type": "application/x-www-form-urlencoded"
},
"body": "foo1=$foo1&foo2=$foo2&foo3=$foo3"

View File

@@ -14,7 +14,7 @@ teststeps:
variables:
foo1: ${ENV(USERNAME)}
foo2: bar21
sum_v: "${SumTwoInt(1, 2)}"
sum_v: "${sum_two_int(1, 2)}"
request:
method: GET
url: $base_url/get
@@ -23,7 +23,7 @@ teststeps:
foo2: $foo2
sum_v: $sum_v
headers:
User-Agent: funplugin/${GetVersion()}
User-Agent: funplugin/${get_version()}
extract:
foo3: "body.args.foo2"
validate:
@@ -40,7 +40,7 @@ teststeps:
method: POST
url: $base_url/post
headers:
User-Agent: funplugin/${GetVersion()}
User-Agent: funplugin/${get_version()}
Content-Type: "text/plain"
body: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
validate:
@@ -54,7 +54,7 @@ teststeps:
method: POST
url: $base_url/post
headers:
User-Agent: funplugin/${GetVersion()}
User-Agent: funplugin/${get_version()}
Content-Type: "application/x-www-form-urlencoded"
body: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
validate: