mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-03 06:49:38 +08:00
fix: unittests
This commit is contained in:
@@ -10,7 +10,7 @@ func TestBoomerStandaloneRun(t *testing.T) {
|
||||
defer removeHashicorpGoPlugin()
|
||||
|
||||
testcase1 := &TestCase{
|
||||
Config: NewConfig("TestCase1").SetBaseURL(HTTP_BIN_URL),
|
||||
Config: NewConfig("TestCase1").SetBaseURL("https://postman-echo.com"),
|
||||
TestSteps: []IStep{
|
||||
NewStep("headers").
|
||||
GET("/headers").
|
||||
|
||||
@@ -7,12 +7,11 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
const HTTP_BIN_URL = "http://127.0.0.1:80"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
||||
)
|
||||
|
||||
func buildHashicorpGoPlugin() {
|
||||
log.Info().Msg("[init] build hashicorp go plugin")
|
||||
@@ -65,31 +64,26 @@ func assertRunTestCases(t *testing.T) {
|
||||
refCase := TestCasePath(demoTestCaseWithPluginJSONPath)
|
||||
testcase1 := &TestCase{
|
||||
Config: NewConfig("TestCase1").
|
||||
SetBaseURL(HTTP_BIN_URL),
|
||||
SetBaseURL("https://postman-echo.com"),
|
||||
TestSteps: []IStep{
|
||||
NewStep("testcase1-step1").
|
||||
GET("/headers").
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"),
|
||||
NewStep("testcase1-step2").
|
||||
GET("/user-agent").
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"),
|
||||
NewStep("testcase1-step3").CallRefCase(
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check http response Content-Type"),
|
||||
NewStep("testcase1-step2").CallRefCase(
|
||||
&TestCase{
|
||||
Config: NewConfig("testcase1-step3-ref-case").SetBaseURL(HTTP_BIN_URL),
|
||||
Config: NewConfig("testcase1-step3-ref-case").SetBaseURL("https://postman-echo.com"),
|
||||
TestSteps: []IStep{
|
||||
NewStep("ip").
|
||||
GET("/ip").
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"),
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check http response Content-Type"),
|
||||
},
|
||||
},
|
||||
),
|
||||
NewStep("testcase1-step4").CallRefCase(&refCase),
|
||||
NewStep("testcase1-step3").CallRefCase(&refCase),
|
||||
},
|
||||
}
|
||||
testcase2 := &TestCase{
|
||||
|
||||
@@ -165,7 +165,7 @@ func TestRunCaseWithTimeout(t *testing.T) {
|
||||
testcase1 := &TestCase{
|
||||
Config: NewConfig("TestCase1").
|
||||
SetRequestTimeout(10). // set global timeout to 10s
|
||||
SetBaseURL(HTTP_BIN_URL),
|
||||
SetBaseURL("https://postman-echo.com"),
|
||||
TestSteps: []IStep{
|
||||
NewStep("step1").
|
||||
GET("/delay/1").
|
||||
@@ -181,7 +181,7 @@ func TestRunCaseWithTimeout(t *testing.T) {
|
||||
testcase2 := &TestCase{
|
||||
Config: NewConfig("TestCase2").
|
||||
SetRequestTimeout(10). // set global timeout to 10s
|
||||
SetBaseURL(HTTP_BIN_URL),
|
||||
SetBaseURL("https://postman-echo.com"),
|
||||
TestSteps: []IStep{
|
||||
NewStep("step1").
|
||||
GET("/delay/11").
|
||||
@@ -198,7 +198,7 @@ func TestRunCaseWithTimeout(t *testing.T) {
|
||||
testcase3 := &TestCase{
|
||||
Config: NewConfig("TestCase3").
|
||||
SetRequestTimeout(10).
|
||||
SetBaseURL(HTTP_BIN_URL),
|
||||
SetBaseURL("https://postman-echo.com"),
|
||||
TestSteps: []IStep{
|
||||
NewStep("step2").
|
||||
GET("/delay/11").
|
||||
|
||||
@@ -6,12 +6,10 @@ import (
|
||||
"github.com/httprunner/httprunner/v4/hrp"
|
||||
)
|
||||
|
||||
const HTTP_BIN_URL = "http://127.0.0.1:80"
|
||||
|
||||
func TestCaseUploadFile(t *testing.T) {
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.NewConfig("test upload file to httpbin").
|
||||
SetBaseURL(HTTP_BIN_URL).
|
||||
SetBaseURL("https://httpbin.org").
|
||||
WithVariables(map[string]interface{}{"upload_file": "test.env"}),
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.NewStep("upload file explicitly").
|
||||
|
||||
Reference in New Issue
Block a user