From c712aa425ebfeafbb24d18cccc2be3cba04f931b Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sat, 22 Jul 2023 00:18:21 +0800 Subject: [PATCH] change: replace httpbin.org with docker service --- .github/workflows/smoketest.yml | 5 +++++ .github/workflows/unittest.yml | 5 +++++ hrp/boomer_test.go | 2 +- hrp/internal/scaffold/templates/plugin/debugtalk_gen.go | 2 +- hrp/runner_test.go | 6 ++++-- hrp/step_request_test.go | 6 +++--- hrp/tests/upload_test.go | 4 +++- 7 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/smoketest.yml b/.github/workflows/smoketest.yml index 8e989ab6..b530fbc6 100644 --- a/.github/workflows/smoketest.yml +++ b/.github/workflows/smoketest.yml @@ -64,6 +64,11 @@ jobs: - 1.18.x os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} + services: + service-httpbin: + image: kennethreitz/httpbin + ports: + - 80:80 steps: - name: Install Go uses: actions/setup-go@v2 diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 5e4b3d89..ead19e77 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -71,6 +71,11 @@ jobs: - 1.18.x os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} + services: + service-httpbin: + image: kennethreitz/httpbin + ports: + - 80:80 steps: - name: Install Go uses: actions/setup-go@v2 diff --git a/hrp/boomer_test.go b/hrp/boomer_test.go index 9eadc91a..69be135d 100644 --- a/hrp/boomer_test.go +++ b/hrp/boomer_test.go @@ -10,7 +10,7 @@ func TestBoomerStandaloneRun(t *testing.T) { defer removeHashicorpGoPlugin() testcase1 := &TestCase{ - Config: NewConfig("TestCase1").SetBaseURL("https://httpbin.org"), + Config: NewConfig("TestCase1").SetBaseURL(HTTP_BIN_URL), TestSteps: []IStep{ NewStep("headers"). GET("/headers"). diff --git a/hrp/internal/scaffold/templates/plugin/debugtalk_gen.go b/hrp/internal/scaffold/templates/plugin/debugtalk_gen.go index cec9b779..68e22a16 100644 --- a/hrp/internal/scaffold/templates/plugin/debugtalk_gen.go +++ b/hrp/internal/scaffold/templates/plugin/debugtalk_gen.go @@ -1,4 +1,4 @@ -// NOTE: Generated By hrp v4.3.4, DO NOT EDIT! +// NOTE: Generated By hrp v4.3.5, DO NOT EDIT! package main import ( diff --git a/hrp/runner_test.go b/hrp/runner_test.go index 9a0280bb..7c6a04ea 100644 --- a/hrp/runner_test.go +++ b/hrp/runner_test.go @@ -12,6 +12,8 @@ import ( "github.com/stretchr/testify/assert" ) +const HTTP_BIN_URL = "http://127.0.0.1:80" + func buildHashicorpGoPlugin() { log.Info().Msg("[init] build hashicorp go plugin") err := BuildPlugin(tmpl("plugin/debugtalk.go"), tmpl("debugtalk.bin")) @@ -63,7 +65,7 @@ func assertRunTestCases(t *testing.T) { refCase := TestCasePath(demoTestCaseWithPluginJSONPath) testcase1 := &TestCase{ Config: NewConfig("TestCase1"). - SetBaseURL("https://httpbin.org"), + SetBaseURL(HTTP_BIN_URL), TestSteps: []IStep{ NewStep("testcase1-step1"). GET("/headers"). @@ -77,7 +79,7 @@ func assertRunTestCases(t *testing.T) { AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"), NewStep("testcase1-step3").CallRefCase( &TestCase{ - Config: NewConfig("testcase1-step3-ref-case").SetBaseURL("https://httpbin.org"), + Config: NewConfig("testcase1-step3-ref-case").SetBaseURL(HTTP_BIN_URL), TestSteps: []IStep{ NewStep("ip"). GET("/ip"). diff --git a/hrp/step_request_test.go b/hrp/step_request_test.go index 7b476ba9..4fe095df 100644 --- a/hrp/step_request_test.go +++ b/hrp/step_request_test.go @@ -165,7 +165,7 @@ func TestRunCaseWithTimeout(t *testing.T) { testcase1 := &TestCase{ Config: NewConfig("TestCase1"). SetRequestTimeout(10). // set global timeout to 10s - SetBaseURL("https://httpbin.org"), + SetBaseURL(HTTP_BIN_URL), 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("https://httpbin.org"), + SetBaseURL(HTTP_BIN_URL), TestSteps: []IStep{ NewStep("step1"). GET("/delay/11"). @@ -198,7 +198,7 @@ func TestRunCaseWithTimeout(t *testing.T) { testcase3 := &TestCase{ Config: NewConfig("TestCase3"). SetRequestTimeout(10). - SetBaseURL("https://httpbin.org"), + SetBaseURL(HTTP_BIN_URL), TestSteps: []IStep{ NewStep("step2"). GET("/delay/11"). diff --git a/hrp/tests/upload_test.go b/hrp/tests/upload_test.go index d0c93017..ae0c9546 100644 --- a/hrp/tests/upload_test.go +++ b/hrp/tests/upload_test.go @@ -6,10 +6,12 @@ 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("https://httpbin.org"). + SetBaseURL(HTTP_BIN_URL). WithVariables(map[string]interface{}{"upload_file": "test.env"}), TestSteps: []hrp.IStep{ hrp.NewStep("upload file explicitly").