From 96c136e2be7ac28854d056f5e9ca5b7646418b4d Mon Sep 17 00:00:00 2001 From: debugtalk Date: Sat, 16 Oct 2021 23:14:16 +0800 Subject: [PATCH] refactor: rename to hrp --- .github/workflows/main.yml | 2 +- README.md | 36 ++++++------ boomer.go | 2 +- boomer_test.go | 2 +- convert.go | 2 +- convert_test.go | 4 +- docs/cmd/hrp.md | 25 ++++++++ docs/cmd/{httpboomer_boom.md => hrp_boom.md} | 14 ++--- docs/cmd/hrp_har2case.md | 23 ++++++++ docs/cmd/hrp_run.md | 33 +++++++++++ docs/cmd/httpboomer.md | 25 -------- docs/cmd/httpboomer_har2case.md | 23 -------- docs/cmd/httpboomer_run.md | 32 ----------- docs/doc_test.go | 2 +- examples/demo.har | 2 +- examples/demo.json | 2 +- examples/demo.yaml | 2 +- examples/demo_test.go | 18 +++--- examples/extract_test.go | 34 +++++------ examples/function_test.go | 18 +++--- examples/request_test.go | 30 +++++----- examples/validate_test.go | 20 +++---- examples/variables_test.go | 60 ++++++++++---------- extract.go | 2 +- go.mod | 4 +- har2case/README.md | 2 +- har2case/core.go | 33 +++++------ har2case/core_test.go | 2 +- hrp/README.md | 1 + {httpboomer => hrp}/cmd/boom.go | 14 ++--- {httpboomer => hrp}/cmd/har2case.go | 2 +- {httpboomer => hrp}/cmd/root.go | 10 ++-- {httpboomer => hrp}/cmd/run.go | 14 ++--- hrp/main.go | 7 +++ httpboomer/README.md | 1 - httpboomer/main.go | 7 --- models.go | 3 +- parser.go | 4 +- parser_test.go | 2 +- response.go | 4 +- runner.go | 2 +- runner_test.go | 2 +- step.go | 2 +- step_test.go | 10 ++-- validate.go | 2 +- version.go | 2 +- 46 files changed, 273 insertions(+), 270 deletions(-) create mode 100644 docs/cmd/hrp.md rename docs/cmd/{httpboomer_boom.md => hrp_boom.md} (75%) create mode 100644 docs/cmd/hrp_har2case.md create mode 100644 docs/cmd/hrp_run.md delete mode 100644 docs/cmd/httpboomer.md delete mode 100644 docs/cmd/httpboomer_har2case.md delete mode 100644 docs/cmd/httpboomer_run.md create mode 100644 hrp/README.md rename {httpboomer => hrp}/cmd/boom.go (83%) rename {httpboomer => hrp}/cmd/har2case.go (95%) rename {httpboomer => hrp}/cmd/root.go (71%) rename {httpboomer => hrp}/cmd/run.go (66%) create mode 100644 hrp/main.go delete mode 100644 httpboomer/README.md delete mode 100644 httpboomer/main.go diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a0c2c2d8..c90216ab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 with: - name: httpboomer # User defined upload name. Visible in Codecov UI + name: hrp(HttpRunner+) # User defined upload name. Visible in Codecov UI token: ${{ secrets.CODECOV_TOKEN }} # Repository upload token file: ./cover.out # Path to coverage file to upload flags: unittests # Flag upload to group coverage metrics diff --git a/README.md b/README.md index 084f4dfe..7d55b597 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -# HttpBoomer +# HttpRunner+ (hrp) -[![Go Reference](https://pkg.go.dev/badge/github.com/httprunner/httpboomer.svg)](https://pkg.go.dev/github.com/httprunner/httpboomer) -[![Github Actions](https://github.com/httprunner/HttpBoomer/actions/workflows/main.yml/badge.svg)](https://github.com/httprunner/HttpBoomer/actions) -[![codecov](https://codecov.io/gh/httprunner/HttpBoomer/branch/main/graph/badge.svg?token=HPCQWCD7KO)](https://codecov.io/gh/httprunner/HttpBoomer) -[![Go Report Card](https://goreportcard.com/badge/github.com/httprunner/HttpBoomer)](https://goreportcard.com/report/github.com/httprunner/HttpBoomer) -[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B27856%2Fgithub.com%2Fhttprunner%2FHttpBoomer.svg?type=shield)](https://app.fossa.com/reports/fb0e64a7-7dcf-48bb-8de9-8f0e016b903b) +[![Go Reference](https://pkg.go.dev/badge/github.com/httprunner/hrp.svg)](https://pkg.go.dev/github.com/httprunner/hrp) +[![Github Actions](https://github.com/httprunner/hrp/actions/workflows/main.yml/badge.svg)](https://github.com/httprunner/hrp/actions) +[![codecov](https://codecov.io/gh/httprunner/hrp/branch/main/graph/badge.svg?token=HPCQWCD7KO)](https://codecov.io/gh/httprunner/hrp) +[![Go Report Card](https://goreportcard.com/badge/github.com/httprunner/hrp)](https://goreportcard.com/report/github.com/httprunner/hrp) +[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B27856%2Fgithub.com%2Fhttprunner%2Fhrp.svg?type=shield)](https://app.fossa.com/reports/fb0e64a7-7dcf-48bb-8de9-8f0e016b903b) -> HttpBoomer = [HttpRunner] + [Boomer] +> hrp (HttpRunnerPlus) = [HttpRunner] + [Boomer] -HttpBoomer is a golang implementation of [HttpRunner]. Ideally, HttpBoomer will be fully compatible with HttpRunner, including testcase format and usage. What's more, HttpBoomer will integrate Boomer natively to be a better load generator for [locust]. +`hrp` is a golang implementation of [HttpRunner]. Ideally, `hrp` will be fully compatible with HttpRunner, including testcase format and usage. What's more, `hrp` will integrate Boomer natively to be a better load generator for [locust]. ## Key Features @@ -27,23 +27,23 @@ HttpBoomer is a golang implementation of [HttpRunner]. Ideally, HttpBoomer will ### Install ```bash -$ go get -u github.com/httprunner/httpboomer +$ go get -u github.com/httprunner/hrp ``` ### Examples -This is an example of HttpBoomer testcase. You can find more in the [`examples`][examples] directory. +This is an example of `hrp` testcase. You can find more in the [`examples`][examples] directory. ```go import ( "testing" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) func TestCaseDemo(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "demo with complex mechanisms", BaseURL: "https://postman-echo.com", Variables: map[string]interface{}{ // global level variables @@ -54,8 +54,8 @@ func TestCaseDemo(t *testing.T) { "varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function }, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). WithVariables(map[string]interface{}{ // step level variables "n": 3, // inherit config level variables if not set in step level, a/varFoo1 "b": 34.5, // override config level variable if existed, n/b/varFoo2 @@ -63,7 +63,7 @@ func TestCaseDemo(t *testing.T) { }). GET("/get"). WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). // request with headers + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers Extract(). WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath Validate(). @@ -72,7 +72,7 @@ func TestCaseDemo(t *testing.T) { AssertLengthEqual("body.args.foo1", 5, "check args foo1"). // validate response body with jmespath AssertLengthEqual("$varFoo1", 5, "check args foo1"). // assert with extracted variable from current step AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string - httpboomer.Step("post json data"). + hrp.Step("post json data"). POST("/post"). WithJSON(map[string]interface{}{ "foo1": "$varFoo1", // reference former extracted variable @@ -85,7 +85,7 @@ func TestCaseDemo(t *testing.T) { }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/boomer.go b/boomer.go index eb4c03cf..371209bb 100644 --- a/boomer.go +++ b/boomer.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "time" diff --git a/boomer_test.go b/boomer_test.go index 8ce53971..72fb1c52 100644 --- a/boomer_test.go +++ b/boomer_test.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "testing" diff --git a/convert.go b/convert.go index e22ad9cd..b38f49ff 100644 --- a/convert.go +++ b/convert.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "bytes" diff --git a/convert_test.go b/convert_test.go index 40adb3bc..b772b746 100644 --- a/convert_test.go +++ b/convert_test.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "os" @@ -28,7 +28,7 @@ var demoTestCase = &TestCase{ }). GET("/get"). WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). // request with headers + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers Extract(). WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath Validate(). diff --git a/docs/cmd/hrp.md b/docs/cmd/hrp.md new file mode 100644 index 00000000..00513a78 --- /dev/null +++ b/docs/cmd/hrp.md @@ -0,0 +1,25 @@ +## hrp + +One-stop solution for HTTP(S) testing. + +### Synopsis + +hrp(HttpRunnerPlus) is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ + +License: Apache-2.0 +Github: https://github.com/httprunner/hrp +Copyright 2021 debugtalk + +### Options + +``` + -h, --help help for hrp +``` + +### SEE ALSO + +* [hrp boom](hrp_boom.md) - run load test with boomer +* [hrp har2case](hrp_har2case.md) - Convert HAR to json/yaml testcase files +* [hrp run](hrp_run.md) - run API test + +###### Auto generated by spf13/cobra on 16-Oct-2021 diff --git a/docs/cmd/httpboomer_boom.md b/docs/cmd/hrp_boom.md similarity index 75% rename from docs/cmd/httpboomer_boom.md rename to docs/cmd/hrp_boom.md index 975f13ad..bb7e3cbb 100644 --- a/docs/cmd/httpboomer_boom.md +++ b/docs/cmd/hrp_boom.md @@ -1,4 +1,4 @@ -## httpboomer boom +## hrp boom run load test with boomer @@ -7,15 +7,15 @@ run load test with boomer run yaml/json testcase files for load test ``` -httpboomer boom [flags] +hrp boom [flags] ``` ### Examples ``` - $ httpboomer boom demo.json # run specified json testcase file - $ httpboomer boom demo.yaml # run specified yaml testcase file - $ httpboomer boom examples/ # run testcases in specified folder + $ hrp boom demo.json # run specified json testcase file + $ hrp boom demo.yaml # run specified yaml testcase file + $ hrp boom examples/ # run testcases in specified folder ``` ### Options @@ -35,6 +35,6 @@ httpboomer boom [flags] ### SEE ALSO -* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing. +* [hrp](hrp.md) - One-stop solution for HTTP(S) testing. -###### Auto generated by spf13/cobra on 11-Oct-2021 +###### Auto generated by spf13/cobra on 16-Oct-2021 diff --git a/docs/cmd/hrp_har2case.md b/docs/cmd/hrp_har2case.md new file mode 100644 index 00000000..d1281b12 --- /dev/null +++ b/docs/cmd/hrp_har2case.md @@ -0,0 +1,23 @@ +## hrp har2case + +Convert HAR to json/yaml testcase files + +### Synopsis + +Convert HAR to json/yaml testcase files + +``` +hrp har2case path... [flags] +``` + +### Options + +``` + -h, --help help for har2case +``` + +### SEE ALSO + +* [hrp](hrp.md) - One-stop solution for HTTP(S) testing. + +###### Auto generated by spf13/cobra on 16-Oct-2021 diff --git a/docs/cmd/hrp_run.md b/docs/cmd/hrp_run.md new file mode 100644 index 00000000..42f8d4cb --- /dev/null +++ b/docs/cmd/hrp_run.md @@ -0,0 +1,33 @@ +## hrp run + +run API test + +### Synopsis + +run yaml/json testcase files for API test + +``` +hrp run path... [flags] +``` + +### Examples + +``` + $ hrp run demo.json # run specified json testcase file + $ hrp run demo.yaml # run specified yaml testcase file + $ hrp run examples/ # run testcases in specified folder +``` + +### Options + +``` + -h, --help help for run + -p, --proxy-url string set proxy url + -s, --silent disable logging request & response details +``` + +### SEE ALSO + +* [hrp](hrp.md) - One-stop solution for HTTP(S) testing. + +###### Auto generated by spf13/cobra on 16-Oct-2021 diff --git a/docs/cmd/httpboomer.md b/docs/cmd/httpboomer.md deleted file mode 100644 index 9db2bdf1..00000000 --- a/docs/cmd/httpboomer.md +++ /dev/null @@ -1,25 +0,0 @@ -## httpboomer - -One-stop solution for HTTP(S) testing. - -### Synopsis - -HttpBoomer is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ - -License: Apache-2.0 -Github: https://github.com/httprunner/httpboomer -Copyright 2021 debugtalk - -### Options - -``` - -h, --help help for httpboomer -``` - -### SEE ALSO - -* [httpboomer boom](httpboomer_boom.md) - run load test with boomer -* [httpboomer har2case](httpboomer_har2case.md) - Convert HAR to json/yaml testcase files -* [httpboomer run](httpboomer_run.md) - run API test - -###### Auto generated by spf13/cobra on 11-Oct-2021 diff --git a/docs/cmd/httpboomer_har2case.md b/docs/cmd/httpboomer_har2case.md deleted file mode 100644 index d1d82222..00000000 --- a/docs/cmd/httpboomer_har2case.md +++ /dev/null @@ -1,23 +0,0 @@ -## httpboomer har2case - -Convert HAR to json/yaml testcase files - -### Synopsis - -Convert HAR to json/yaml testcase files - -``` -httpboomer har2case path... [flags] -``` - -### Options - -``` - -h, --help help for har2case -``` - -### SEE ALSO - -* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing. - -###### Auto generated by spf13/cobra on 11-Oct-2021 diff --git a/docs/cmd/httpboomer_run.md b/docs/cmd/httpboomer_run.md deleted file mode 100644 index 6a5a0ef0..00000000 --- a/docs/cmd/httpboomer_run.md +++ /dev/null @@ -1,32 +0,0 @@ -## httpboomer run - -run API test - -### Synopsis - -run yaml/json testcase files for API test - -``` -httpboomer run path... [flags] -``` - -### Examples - -``` - $ httpboomer run demo.json # run specified json testcase file - $ httpboomer run demo.yaml # run specified yaml testcase file - $ httpboomer run examples/ # run testcases in specified folder -``` - -### Options - -``` - -h, --help help for run - -s, --silent Disable logging request & response details -``` - -### SEE ALSO - -* [httpboomer](httpboomer.md) - One-stop solution for HTTP(S) testing. - -###### Auto generated by spf13/cobra on 11-Oct-2021 diff --git a/docs/doc_test.go b/docs/doc_test.go index ada217a1..6dde9ac8 100644 --- a/docs/doc_test.go +++ b/docs/doc_test.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra/doc" - "github.com/httprunner/httpboomer/httpboomer/cmd" + "github.com/httprunner/hrp/hrp/cmd" ) // run this test to generate markdown docs diff --git a/examples/demo.har b/examples/demo.har index 40151473..3a94a304 100644 --- a/examples/demo.har +++ b/examples/demo.har @@ -21,7 +21,7 @@ }, { "name": "User-Agent", - "value": "HttpBoomer" + "value": "HttpRunnerPlus" }, { "name": "Accept-Encoding", diff --git a/examples/demo.json b/examples/demo.json index ffac9d65..855a73dd 100644 --- a/examples/demo.json +++ b/examples/demo.json @@ -21,7 +21,7 @@ "foo2": "$varFoo2" }, "headers": { - "User-Agent": "HttpBoomer" + "User-Agent": "HttpRunnerPlus" } }, "variables": { diff --git a/examples/demo.yaml b/examples/demo.yaml index 63df1984..35eec3c8 100644 --- a/examples/demo.yaml +++ b/examples/demo.yaml @@ -16,7 +16,7 @@ teststeps: foo1: $varFoo1 foo2: $varFoo2 headers: - User-Agent: HttpBoomer + User-Agent: HttpRunnerPlus variables: b: 34.5 "n": 3 diff --git a/examples/demo_test.go b/examples/demo_test.go index b60aa513..301abf80 100644 --- a/examples/demo_test.go +++ b/examples/demo_test.go @@ -3,12 +3,12 @@ package examples import ( "testing" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) func TestCaseDemo(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "demo with complex mechanisms", BaseURL: "https://postman-echo.com", Variables: map[string]interface{}{ // global level variables @@ -19,8 +19,8 @@ func TestCaseDemo(t *testing.T) { "varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function }, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). WithVariables(map[string]interface{}{ // step level variables "n": 3, // inherit config level variables if not set in step level, a/varFoo1 "b": 34.5, // override config level variable if existed, n/b/varFoo2 @@ -28,7 +28,7 @@ func TestCaseDemo(t *testing.T) { }). GET("/get"). WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). // request with headers + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers Extract(). WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath Validate(). @@ -37,7 +37,7 @@ func TestCaseDemo(t *testing.T) { AssertLengthEqual("body.args.foo1", 5, "check args foo1"). // validate response body with jmespath AssertLengthEqual("$varFoo1", 5, "check args foo1"). // assert with extracted variable from current step AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string - httpboomer.Step("post json data"). + hrp.Step("post json data"). POST("/post"). WithBody(map[string]interface{}{ "foo1": "$varFoo1", // reference former extracted variable @@ -47,7 +47,7 @@ func TestCaseDemo(t *testing.T) { AssertEqual("status_code", 200, "check status code"). AssertLengthEqual("body.json.foo1", 5, "check args foo1"). AssertEqual("body.json.foo2", 12.3, "check args foo2"), - httpboomer.Step("post form data"). + hrp.Step("post form data"). POST("/post"). WithParams(map[string]interface{}{ "foo1": "$varFoo1", // reference former extracted variable @@ -60,7 +60,7 @@ func TestCaseDemo(t *testing.T) { }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/extract_test.go b/examples/extract_test.go index bc0aaa63..67e8a654 100644 --- a/examples/extract_test.go +++ b/examples/extract_test.go @@ -3,22 +3,22 @@ package examples import ( "testing" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) // reference extracted variables for validation in the same step func TestCaseExtractStepSingle(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "run request with variables", BaseURL: "https://postman-echo.com", Verify: false, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). WithVariables(map[string]interface{}{ "var1": "bar1", - "agent": "HttpBoomer", + "agent": "HttpRunnerPlus", "expectedStatusCode": 200, }). GET("/get"). @@ -33,11 +33,11 @@ func TestCaseExtractStepSingle(t *testing.T) { AssertEqual("$contentType", "application/json; charset=utf-8", "check header Content-Type"). // assert with extracted variable from current step AssertEqual("$varFoo1", "bar1", "check args foo1"). // assert with extracted variable from current step AssertEqual("body.args.foo2", "bar2", "check args foo2"). - AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"), + AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"), }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } @@ -45,17 +45,17 @@ func TestCaseExtractStepSingle(t *testing.T) { // reference extracted variables from previous step func TestCaseExtractStepAssociation(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "run request with variables", BaseURL: "https://postman-echo.com", Verify: false, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). WithVariables(map[string]interface{}{ "var1": "bar1", - "agent": "HttpBoomer", + "agent": "HttpRunnerPlus", }). GET("/get"). WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}). @@ -70,10 +70,10 @@ func TestCaseExtractStepAssociation(t *testing.T) { AssertEqual("$contentType", "application/json; charset=utf-8", "check header Content-Type"). AssertEqual("$varFoo1", "bar1", "check args foo1"). AssertEqual("body.args.foo2", "bar2", "check args foo2"). - AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"), - httpboomer.Step("post json data"). + AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"), + hrp.Step("post json data"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). Validate(). AssertEqual("status_code", "$statusCode", "check status code"). // assert with extracted variable from previous step @@ -82,7 +82,7 @@ func TestCaseExtractStepAssociation(t *testing.T) { }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/function_test.go b/examples/function_test.go index 5e825724..768224af 100644 --- a/examples/function_test.go +++ b/examples/function_test.go @@ -3,12 +3,12 @@ package examples import ( "testing" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) func TestCaseCallFunction(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "run request with functions", BaseURL: "https://postman-echo.com", Verify: false, @@ -18,20 +18,20 @@ func TestCaseCallFunction(t *testing.T) { "b": 3.45, }, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). GET("/get"). WithParams(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). Extract(). WithJmesPath("body.args.foo1", "varFoo1"). Validate(). AssertEqual("status_code", 200, "check status code"). AssertLengthEqual("body.args.foo1", 5, "check args foo1"). AssertEqual("body.args.foo2", "12.3", "check args foo2"), // notice: request params value will be converted to string - httpboomer.Step("post json data with functions"). + hrp.Step("post json data with functions"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}). Validate(). AssertEqual("status_code", 200, "check status code"). @@ -40,7 +40,7 @@ func TestCaseCallFunction(t *testing.T) { }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/request_test.go b/examples/request_test.go index 58578291..433e593e 100644 --- a/examples/request_test.go +++ b/examples/request_test.go @@ -3,53 +3,53 @@ package examples import ( "testing" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) func TestCaseBasicRequest(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "request methods testcase in hardcode", BaseURL: "https://postman-echo.com", Verify: false, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). GET("/get"). WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). Validate(). AssertEqual("status_code", 200, "check status code"). AssertEqual("headers.Connection", "keep-alive", "check header Connection"). AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). AssertEqual("body.args.foo1", "bar1", "check args foo1"). AssertEqual("body.args.foo2", "bar2", "check args foo2"), - httpboomer.Step("post raw text"). + hrp.Step("post raw text"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "text/plain"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "text/plain"}). WithBody("This is expected to be sent back as part of response body."). Validate(). AssertEqual("status_code", 200, "check status code"). AssertEqual("body.data", "This is expected to be sent back as part of response body.", "check data"), - httpboomer.Step("post form data"). + hrp.Step("post form data"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "application/x-www-form-urlencoded"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "application/x-www-form-urlencoded"}). WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). Validate(). AssertEqual("status_code", 200, "check status code"). AssertEqual("body.form.foo1", "bar1", "check form foo1"). AssertEqual("body.form.foo2", "bar2", "check form foo2"), - httpboomer.Step("post json data"). + hrp.Step("post json data"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). Validate(). AssertEqual("status_code", 200, "check status code"). AssertEqual("body.json.foo1", "bar1", "check json foo1"). AssertEqual("body.json.foo2", "bar2", "check json foo2"), - httpboomer.Step("put request"). + hrp.Step("put request"). PUT("/put"). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "text/plain"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "text/plain"}). WithBody("This is expected to be sent back as part of response body."). Validate(). AssertEqual("status_code", 200, "check status code"). @@ -57,7 +57,7 @@ func TestCaseBasicRequest(t *testing.T) { }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/validate_test.go b/examples/validate_test.go index daecd4fb..42cf508f 100644 --- a/examples/validate_test.go +++ b/examples/validate_test.go @@ -3,21 +3,21 @@ package examples import ( "testing" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) func TestCaseValidateStep(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "run request with validation", BaseURL: "https://postman-echo.com", Verify: false, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). WithVariables(map[string]interface{}{ "var1": "bar1", - "agent": "HttpBoomer", + "agent": "HttpRunnerPlus", "expectedStatusCode": 200, }). GET("/get"). @@ -31,11 +31,11 @@ func TestCaseValidateStep(t *testing.T) { AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). // assert response header, with double quotes AssertEqual("body.args.foo1", "bar1", "check args foo1"). // assert response json body with jmespath AssertEqual("body.args.foo2", "bar2", "check args foo2"). - AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"), - httpboomer.Step("get with params"). + AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"), + hrp.Step("get with params"). WithVariables(map[string]interface{}{ "var1": "bar1", - "agent": "HttpBoomer", + "agent": "HttpRunnerPlus", }). GET("/get"). WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}). @@ -51,7 +51,7 @@ func TestCaseValidateStep(t *testing.T) { }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/examples/variables_test.go b/examples/variables_test.go index 225faa3e..edf22cf2 100644 --- a/examples/variables_test.go +++ b/examples/variables_test.go @@ -3,23 +3,23 @@ package examples import ( "testing" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) func TestCaseConfigVariables(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "run request with variables", BaseURL: "https://postman-echo.com", Variables: map[string]interface{}{ "var1": "bar1", - "agent": "HttpBoomer", + "agent": "HttpRunnerPlus", "expectedStatusCode": 200, }, Verify: false, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). GET("/get"). WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}). WithHeaders(map[string]string{"User-Agent": "$agent"}). @@ -29,28 +29,28 @@ func TestCaseConfigVariables(t *testing.T) { AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). AssertEqual("body.args.foo1", "bar1", "check args foo1"). AssertEqual("body.args.foo2", "bar2", "check args foo2"). - AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"), + AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"), }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } } func TestCaseStepVariables(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "run request with variables", BaseURL: "https://postman-echo.com", Verify: false, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). WithVariables(map[string]interface{}{ "var1": "bar1", - "agent": "HttpBoomer", + "agent": "HttpRunnerPlus", "expectedStatusCode": 200, }). GET("/get"). @@ -62,30 +62,30 @@ func TestCaseStepVariables(t *testing.T) { AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). AssertEqual("body.args.foo1", "bar1", "check args foo1"). AssertEqual("body.args.foo2", "bar2", "check args foo2"). - AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"), + AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"), }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } } func TestCaseOverrideConfigVariables(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "run request with variables", BaseURL: "https://postman-echo.com", Variables: map[string]interface{}{ "var1": "bar0", - "agent": "HttpBoomer", + "agent": "HttpRunnerPlus", "expectedStatusCode": 200, }, Verify: false, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). WithVariables(map[string]interface{}{ "var1": "bar1", // override config variable "agent": "$agent", // reference config variable @@ -100,19 +100,19 @@ func TestCaseOverrideConfigVariables(t *testing.T) { AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). AssertEqual("body.args.foo1", "bar1", "check args foo1"). AssertEqual("body.args.foo2", "bar2", "check args foo2"). - AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"), + AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"), }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } } func TestCaseParseVariables(t *testing.T) { - testcase := &httpboomer.TestCase{ - Config: httpboomer.TConfig{ + testcase := &hrp.TestCase{ + Config: hrp.TConfig{ Name: "run request with functions", BaseURL: "https://postman-echo.com", Verify: false, @@ -124,8 +124,8 @@ func TestCaseParseVariables(t *testing.T) { "varFoo2": "${max($a, $b)}", // 12.3 }, }, - TestSteps: []httpboomer.IStep{ - httpboomer.Step("get with params"). + TestSteps: []hrp.IStep{ + hrp.Step("get with params"). WithVariables(map[string]interface{}{ "n": 3, "b": 34.5, @@ -133,16 +133,16 @@ func TestCaseParseVariables(t *testing.T) { }). GET("/get"). WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). Extract(). WithJmesPath("body.args.foo1", "varFoo1"). Validate(). AssertEqual("status_code", 200, "check status code"). AssertLengthEqual("body.args.foo1", 5, "check args foo1"). AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string - httpboomer.Step("post json data with functions"). + hrp.Step("post json data with functions"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}). Validate(). AssertEqual("status_code", 200, "check status code"). @@ -151,7 +151,7 @@ func TestCaseParseVariables(t *testing.T) { }, } - err := httpboomer.Run(t, testcase) + err := hrp.Run(t, testcase) if err != nil { t.Fatalf("run testcase error: %v", err) } diff --git a/extract.go b/extract.go index 97669990..5dc8d839 100644 --- a/extract.go +++ b/extract.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import "fmt" diff --git a/go.mod b/go.mod index f275a22e..18ba428d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/httprunner/httpboomer +module github.com/httprunner/hrp go 1.16 @@ -11,7 +11,7 @@ require ( github.com/maja42/goval v1.2.1 github.com/myzhan/boomer v1.6.0 github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/errors v0.9.1 github.com/shirou/gopsutil v3.21.8+incompatible // indirect github.com/spf13/cobra v1.2.1 github.com/stretchr/testify v1.7.0 diff --git a/har2case/README.md b/har2case/README.md index 3cde2661..08c0b4dc 100644 --- a/har2case/README.md +++ b/har2case/README.md @@ -1,6 +1,6 @@ # har2case -Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner and HttpBoomer. +Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner and HttpRunner+. ## Install diff --git a/har2case/core.go b/har2case/core.go index 6ed95761..04007190 100644 --- a/har2case/core.go +++ b/har2case/core.go @@ -11,8 +11,9 @@ import ( "path/filepath" "strings" - "github.com/httprunner/httpboomer" "github.com/pkg/errors" + + "github.com/httprunner/hrp" ) func NewHAR(path string) *HAR { @@ -49,13 +50,13 @@ func (h *HAR) GenYAML() (yamlPath string, err error) { return } -func (h *HAR) makeTestCase() (*httpboomer.TCase, error) { +func (h *HAR) makeTestCase() (*hrp.TCase, error) { teststeps, err := h.prepareTestSteps() if err != nil { return nil, err } - tCase := &httpboomer.TCase{ + tCase := &hrp.TCase{ Config: *h.prepareConfig(), TestSteps: teststeps, } @@ -83,21 +84,21 @@ func (h *HAR) load() (*Har, error) { return har, nil } -func (h *HAR) prepareConfig() *httpboomer.TConfig { - return &httpboomer.TConfig{ +func (h *HAR) prepareConfig() *hrp.TConfig { + return &hrp.TConfig{ Name: "testcase description", Variables: make(map[string]interface{}), Verify: false, } } -func (h *HAR) prepareTestSteps() ([]*httpboomer.TStep, error) { +func (h *HAR) prepareTestSteps() ([]*hrp.TStep, error) { har, err := h.load() if err != nil { return nil, err } - var steps []*httpboomer.TStep + var steps []*hrp.TStep for _, entry := range har.Log.Entries { step, err := h.prepareTestStep(&entry) if err != nil { @@ -109,12 +110,12 @@ func (h *HAR) prepareTestSteps() ([]*httpboomer.TStep, error) { return steps, nil } -func (h *HAR) prepareTestStep(entry *Entry) (*httpboomer.TStep, error) { +func (h *HAR) prepareTestStep(entry *Entry) (*hrp.TStep, error) { log.Printf("[prepareTestStep] %v %v", entry.Request.Method, entry.Request.URL) tStep := &TStep{ - TStep: httpboomer.TStep{ - Request: &httpboomer.TRequest{}, - Validators: make([]httpboomer.TValidator, 0), + TStep: hrp.TStep{ + Request: &hrp.TRequest{}, + Validators: make([]hrp.TValidator, 0), }, } if err := tStep.makeRequestMethod(entry); err != nil { @@ -142,11 +143,11 @@ func (h *HAR) prepareTestStep(entry *Entry) (*httpboomer.TStep, error) { } type TStep struct { - httpboomer.TStep + hrp.TStep } func (s *TStep) makeRequestMethod(entry *Entry) error { - s.Request.Method = httpboomer.EnumHTTPMethod(entry.Request.Method) + s.Request.Method = hrp.EnumHTTPMethod(entry.Request.Method) return nil } @@ -224,7 +225,7 @@ func (s *TStep) makeRequestBody(entry *Entry) error { func (s *TStep) makeValidate(entry *Entry) error { // make validator for response status code - s.Validators = append(s.Validators, httpboomer.TValidator{ + s.Validators = append(s.Validators, hrp.TValidator{ Check: "status_code", Assert: "equals", Expect: entry.Response.Status, @@ -235,7 +236,7 @@ func (s *TStep) makeValidate(entry *Entry) error { for _, header := range entry.Response.Headers { // assert Content-Type if strings.EqualFold(header.Name, "Content-Type") { - s.Validators = append(s.Validators, httpboomer.TValidator{ + s.Validators = append(s.Validators, hrp.TValidator{ Check: "headers.Content-Type", Assert: "equals", Expect: header.Value, @@ -276,7 +277,7 @@ func (s *TStep) makeValidate(entry *Entry) error { case []interface{}: continue default: - s.Validators = append(s.Validators, httpboomer.TValidator{ + s.Validators = append(s.Validators, hrp.TValidator{ Check: fmt.Sprintf("body.%s", key), Assert: "equals", Expect: v, diff --git a/har2case/core_test.go b/har2case/core_test.go index 4f509f8b..eab15858 100644 --- a/har2case/core_test.go +++ b/har2case/core_test.go @@ -79,7 +79,7 @@ func TestMakeTestCase(t *testing.T) { } // make request headers - if !assert.Equal(t, "HttpBoomer", tCase.TestSteps[0].Request.Headers["User-Agent"]) { + if !assert.Equal(t, "HttpRunnerPlus", tCase.TestSteps[0].Request.Headers["User-Agent"]) { t.Fail() } if !assert.Equal(t, "postman-echo.com", tCase.TestSteps[0].Request.Headers["Host"]) { diff --git a/hrp/README.md b/hrp/README.md new file mode 100644 index 00000000..81e75b9a --- /dev/null +++ b/hrp/README.md @@ -0,0 +1 @@ +# HttpRunner+ cli diff --git a/httpboomer/cmd/boom.go b/hrp/cmd/boom.go similarity index 83% rename from httpboomer/cmd/boom.go rename to hrp/cmd/boom.go index 08c8d7d9..118f8083 100644 --- a/httpboomer/cmd/boom.go +++ b/hrp/cmd/boom.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/cobra" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) // boomCmd represents the boom command @@ -13,16 +13,16 @@ var boomCmd = &cobra.Command{ Use: "boom", Short: "run load test with boomer", Long: `run yaml/json testcase files for load test`, - Example: ` $ httpboomer boom demo.json # run specified json testcase file - $ httpboomer boom demo.yaml # run specified yaml testcase file - $ httpboomer boom examples/ # run testcases in specified folder`, + Example: ` $ hrp boom demo.json # run specified json testcase file + $ hrp boom demo.yaml # run specified yaml testcase file + $ hrp boom examples/ # run testcases in specified folder`, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - var paths []httpboomer.ITestCase + var paths []hrp.ITestCase for _, arg := range args { - paths = append(paths, &httpboomer.TestCasePath{Path: arg}) + paths = append(paths, &hrp.TestCasePath{Path: arg}) } - boomer := httpboomer.NewBoomer(masterHost, masterPort) + boomer := hrp.NewBoomer(masterHost, masterPort) boomer.EnableCPUProfile(cpuProfile, cpuProfileDuration) boomer.EnableMemoryProfile(memoryProfile, memoryProfileDuration) boomer.Run(paths...) diff --git a/httpboomer/cmd/har2case.go b/hrp/cmd/har2case.go similarity index 95% rename from httpboomer/cmd/har2case.go rename to hrp/cmd/har2case.go index 7492c63c..b0c579a9 100644 --- a/httpboomer/cmd/har2case.go +++ b/hrp/cmd/har2case.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" - "github.com/httprunner/httpboomer/har2case" + "github.com/httprunner/hrp/har2case" ) // har2caseCmd represents the har2case command diff --git a/httpboomer/cmd/root.go b/hrp/cmd/root.go similarity index 71% rename from httpboomer/cmd/root.go rename to hrp/cmd/root.go index ceeb7d06..66fe373f 100644 --- a/httpboomer/cmd/root.go +++ b/hrp/cmd/root.go @@ -6,19 +6,19 @@ import ( "github.com/spf13/cobra" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) // RootCmd represents the base command when called without any subcommands var RootCmd = &cobra.Command{ - Use: "httpboomer", + Use: "hrp", Short: "One-stop solution for HTTP(S) testing.", - Long: `HttpBoomer is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ + Long: `hrp(HttpRunnerPlus) is the next generation for HttpRunner. Enjoy! ✨ 🚀 ✨ License: Apache-2.0 -Github: https://github.com/httprunner/httpboomer +Github: https://github.com/httprunner/hrp Copyright 2021 debugtalk`, - Version: httpboomer.VERSION, + Version: hrp.VERSION, } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/httpboomer/cmd/run.go b/hrp/cmd/run.go similarity index 66% rename from httpboomer/cmd/run.go rename to hrp/cmd/run.go index b67bb918..782cff8c 100644 --- a/httpboomer/cmd/run.go +++ b/hrp/cmd/run.go @@ -3,7 +3,7 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/httprunner/httpboomer" + "github.com/httprunner/hrp" ) // runCmd represents the run command @@ -11,16 +11,16 @@ var runCmd = &cobra.Command{ Use: "run path...", Short: "run API test", Long: `run yaml/json testcase files for API test`, - Example: ` $ httpboomer run demo.json # run specified json testcase file - $ httpboomer run demo.yaml # run specified yaml testcase file - $ httpboomer run examples/ # run testcases in specified folder`, + Example: ` $ hrp run demo.json # run specified json testcase file + $ hrp run demo.yaml # run specified yaml testcase file + $ hrp run examples/ # run testcases in specified folder`, Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - var paths []httpboomer.ITestCase + var paths []hrp.ITestCase for _, arg := range args { - paths = append(paths, &httpboomer.TestCasePath{Path: arg}) + paths = append(paths, &hrp.TestCasePath{Path: arg}) } - runner := httpboomer.NewRunner().SetDebug(!silentFlag) + runner := hrp.NewRunner().SetDebug(!silentFlag) if proxyUrl != "" { runner.SetProxyUrl(proxyUrl) } diff --git a/hrp/main.go b/hrp/main.go new file mode 100644 index 00000000..ccc1f0fe --- /dev/null +++ b/hrp/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/httprunner/hrp/hrp/cmd" + +func main() { + cmd.Execute() +} diff --git a/httpboomer/README.md b/httpboomer/README.md deleted file mode 100644 index 5852febb..00000000 --- a/httpboomer/README.md +++ /dev/null @@ -1 +0,0 @@ -# httpboomer cli diff --git a/httpboomer/main.go b/httpboomer/main.go deleted file mode 100644 index 5d736888..00000000 --- a/httpboomer/main.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/httprunner/httpboomer/httpboomer/cmd" - -func main() { - cmd.Execute() -} diff --git a/models.go b/models.go index 76d88fac..9aafdc60 100644 --- a/models.go +++ b/models.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp type EnumHTTPMethod string @@ -43,6 +43,7 @@ type TValidator struct { type TStep struct { Name string `json:"name" yaml:"name"` + Transaction string `json:"transaction,omitempty" yaml:"transaction,omitempty"` Request *TRequest `json:"request,omitempty" yaml:"request,omitempty"` TestCase *TestCase `json:"testcase,omitempty" yaml:"testcase,omitempty"` Variables map[string]interface{} `json:"variables,omitempty" yaml:"variables,omitempty"` diff --git a/parser.go b/parser.go index df6a356a..59e6ac2e 100644 --- a/parser.go +++ b/parser.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "encoding/json" @@ -9,7 +9,7 @@ import ( "regexp" "strings" - "github.com/httprunner/httpboomer/builtin" + "github.com/httprunner/hrp/builtin" "github.com/maja42/goval" ) diff --git a/parser_test.go b/parser_test.go index 459591d8..33f3ae76 100644 --- a/parser_test.go +++ b/parser_test.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "sort" diff --git a/response.go b/response.go index 7abeb607..01d1e470 100644 --- a/response.go +++ b/response.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "encoding/json" @@ -9,7 +9,7 @@ import ( "github.com/imroc/req" "github.com/jmespath/go-jmespath" - "github.com/httprunner/httpboomer/builtin" + "github.com/httprunner/hrp/builtin" ) func NewResponseObject(t *testing.T, resp *req.Resp) (*ResponseObject, error) { diff --git a/runner.go b/runner.go index 678dc5e2..afc36846 100644 --- a/runner.go +++ b/runner.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "log" diff --git a/runner_test.go b/runner_test.go index b770a964..3328a436 100644 --- a/runner_test.go +++ b/runner_test.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "testing" diff --git a/step.go b/step.go index c73e22ab..3508ca13 100644 --- a/step.go +++ b/step.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import "fmt" diff --git a/step_test.go b/step_test.go index a3033150..a41d3cb8 100644 --- a/step_test.go +++ b/step_test.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "testing" @@ -8,7 +8,7 @@ var ( stepGET = Step("get with params"). GET("/get"). WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). WithCookies(map[string]string{"user": "debugtalk"}). Validate(). AssertEqual("status_code", 200, "check status code"). @@ -19,7 +19,7 @@ var ( stepPOSTData = Step("post form data"). POST("/post"). WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). - WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "application/x-www-form-urlencoded"}). + WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "application/x-www-form-urlencoded"}). WithBody("a=1&b=2"). WithCookies(map[string]string{"user": "debugtalk"}). Validate(). @@ -37,7 +37,7 @@ func TestRunRequestGetToStruct(t *testing.T) { if tStep.Request.Params["foo1"] != "bar1" || tStep.Request.Params["foo2"] != "bar2" { t.Fatalf("tStep.Request.Params mismatch") } - if tStep.Request.Headers["User-Agent"] != "HttpBoomer" { + if tStep.Request.Headers["User-Agent"] != "HttpRunnerPlus" { t.Fatalf("tStep.Request.Headers mismatch") } if tStep.Request.Cookies["user"] != "debugtalk" { @@ -59,7 +59,7 @@ func TestRunRequestPostDataToStruct(t *testing.T) { if tStep.Request.Params["foo1"] != "bar1" || tStep.Request.Params["foo2"] != "bar2" { t.Fatalf("tStep.Request.Params mismatch") } - if tStep.Request.Headers["User-Agent"] != "HttpBoomer" { + if tStep.Request.Headers["User-Agent"] != "HttpRunnerPlus" { t.Fatalf("tStep.Request.Headers mismatch") } if tStep.Request.Cookies["user"] != "debugtalk" { diff --git a/validate.go b/validate.go index abfa226f..f4975ca3 100644 --- a/validate.go +++ b/validate.go @@ -1,4 +1,4 @@ -package httpboomer +package hrp import ( "fmt" diff --git a/version.go b/version.go index 9413b4b9..de4e9491 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ -package httpboomer +package hrp const VERSION = "v0.1.0"