Skip to content

Commit 24aa200

Browse files
test: remove httpbin dependency (#297)
Replace the use of external httpbin service in TestRequestError with a local HTTP server using the net/http/httptest package. This change improves test reliability by eliminating the dependency on an external service.
1 parent 104c0c0 commit 24aa200

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

api_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"encoding/json"
66
"errors"
77
"io"
8+
"net/http"
9+
"net/http/httptest"
810
"os"
911
"testing"
1012

@@ -226,8 +228,13 @@ func TestAPIErrorUnmarshalJSONInvalidMessage(t *testing.T) {
226228
func TestRequestError(t *testing.T) {
227229
var err error
228230

231+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
232+
w.WriteHeader(http.StatusTeapot)
233+
}))
234+
defer ts.Close()
235+
229236
config := DefaultConfig("dummy")
230-
config.BaseURL = "https://httpbin.org/status/418?"
237+
config.BaseURL = ts.URL
231238
c := NewClientWithConfig(config)
232239
ctx := context.Background()
233240
_, err = c.ListEngines(ctx)

0 commit comments

Comments
 (0)