change: replace httpbin.org with docker service

This commit is contained in:
lilong.129
2023-07-22 00:18:21 +08:00
parent 52fc9c3a17
commit c712aa425e
7 changed files with 22 additions and 8 deletions

View File

@@ -64,6 +64,11 @@ jobs:
- 1.18.x - 1.18.x
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
services:
service-httpbin:
image: kennethreitz/httpbin
ports:
- 80:80
steps: steps:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2

View File

@@ -71,6 +71,11 @@ jobs:
- 1.18.x - 1.18.x
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
services:
service-httpbin:
image: kennethreitz/httpbin
ports:
- 80:80
steps: steps:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2

View File

@@ -10,7 +10,7 @@ func TestBoomerStandaloneRun(t *testing.T) {
defer removeHashicorpGoPlugin() defer removeHashicorpGoPlugin()
testcase1 := &TestCase{ testcase1 := &TestCase{
Config: NewConfig("TestCase1").SetBaseURL("https://httpbin.org"), Config: NewConfig("TestCase1").SetBaseURL(HTTP_BIN_URL),
TestSteps: []IStep{ TestSteps: []IStep{
NewStep("headers"). NewStep("headers").
GET("/headers"). GET("/headers").

View File

@@ -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 package main
import ( import (

View File

@@ -12,6 +12,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
const HTTP_BIN_URL = "http://127.0.0.1:80"
func buildHashicorpGoPlugin() { func buildHashicorpGoPlugin() {
log.Info().Msg("[init] build hashicorp go plugin") log.Info().Msg("[init] build hashicorp go plugin")
err := BuildPlugin(tmpl("plugin/debugtalk.go"), tmpl("debugtalk.bin")) err := BuildPlugin(tmpl("plugin/debugtalk.go"), tmpl("debugtalk.bin"))
@@ -63,7 +65,7 @@ func assertRunTestCases(t *testing.T) {
refCase := TestCasePath(demoTestCaseWithPluginJSONPath) refCase := TestCasePath(demoTestCaseWithPluginJSONPath)
testcase1 := &TestCase{ testcase1 := &TestCase{
Config: NewConfig("TestCase1"). Config: NewConfig("TestCase1").
SetBaseURL("https://httpbin.org"), SetBaseURL(HTTP_BIN_URL),
TestSteps: []IStep{ TestSteps: []IStep{
NewStep("testcase1-step1"). NewStep("testcase1-step1").
GET("/headers"). GET("/headers").
@@ -77,7 +79,7 @@ func assertRunTestCases(t *testing.T) {
AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"), AssertEqual("headers.\"Content-Type\"", "application/json", "check http response Content-Type"),
NewStep("testcase1-step3").CallRefCase( NewStep("testcase1-step3").CallRefCase(
&TestCase{ &TestCase{
Config: NewConfig("testcase1-step3-ref-case").SetBaseURL("https://httpbin.org"), Config: NewConfig("testcase1-step3-ref-case").SetBaseURL(HTTP_BIN_URL),
TestSteps: []IStep{ TestSteps: []IStep{
NewStep("ip"). NewStep("ip").
GET("/ip"). GET("/ip").

View File

@@ -165,7 +165,7 @@ func TestRunCaseWithTimeout(t *testing.T) {
testcase1 := &TestCase{ testcase1 := &TestCase{
Config: NewConfig("TestCase1"). Config: NewConfig("TestCase1").
SetRequestTimeout(10). // set global timeout to 10s SetRequestTimeout(10). // set global timeout to 10s
SetBaseURL("https://httpbin.org"), SetBaseURL(HTTP_BIN_URL),
TestSteps: []IStep{ TestSteps: []IStep{
NewStep("step1"). NewStep("step1").
GET("/delay/1"). GET("/delay/1").
@@ -181,7 +181,7 @@ func TestRunCaseWithTimeout(t *testing.T) {
testcase2 := &TestCase{ testcase2 := &TestCase{
Config: NewConfig("TestCase2"). Config: NewConfig("TestCase2").
SetRequestTimeout(10). // set global timeout to 10s SetRequestTimeout(10). // set global timeout to 10s
SetBaseURL("https://httpbin.org"), SetBaseURL(HTTP_BIN_URL),
TestSteps: []IStep{ TestSteps: []IStep{
NewStep("step1"). NewStep("step1").
GET("/delay/11"). GET("/delay/11").
@@ -198,7 +198,7 @@ func TestRunCaseWithTimeout(t *testing.T) {
testcase3 := &TestCase{ testcase3 := &TestCase{
Config: NewConfig("TestCase3"). Config: NewConfig("TestCase3").
SetRequestTimeout(10). SetRequestTimeout(10).
SetBaseURL("https://httpbin.org"), SetBaseURL(HTTP_BIN_URL),
TestSteps: []IStep{ TestSteps: []IStep{
NewStep("step2"). NewStep("step2").
GET("/delay/11"). GET("/delay/11").

View File

@@ -6,10 +6,12 @@ import (
"github.com/httprunner/httprunner/v4/hrp" "github.com/httprunner/httprunner/v4/hrp"
) )
const HTTP_BIN_URL = "http://127.0.0.1:80"
func TestCaseUploadFile(t *testing.T) { func TestCaseUploadFile(t *testing.T) {
testcase := &hrp.TestCase{ testcase := &hrp.TestCase{
Config: hrp.NewConfig("test upload file to httpbin"). Config: hrp.NewConfig("test upload file to httpbin").
SetBaseURL("https://httpbin.org"). SetBaseURL(HTTP_BIN_URL).
WithVariables(map[string]interface{}{"upload_file": "test.env"}), WithVariables(map[string]interface{}{"upload_file": "test.env"}),
TestSteps: []hrp.IStep{ TestSteps: []hrp.IStep{
hrp.NewStep("upload file explicitly"). hrp.NewStep("upload file explicitly").