MCPcopy Index your code
hub / github.com/labstack/echo / TestFailNextTarget

Function TestFailNextTarget

middleware/proxy_test.go:418–433  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

416}
417
418func TestFailNextTarget(t *testing.T) {
419 url1, err := url.Parse("http://dummy:8080")
420 assert.Nil(t, err)
421
422 e := echo.New()
423 tp := &testProvider{}
424 tp.target = &ProxyTarget{Name: "target 1", URL: url1}
425 tp.err = echo.NewHTTPError(http.StatusInternalServerError, "method could not select target")
426
427 e.Use(Proxy(tp))
428 rec := httptest.NewRecorder()
429 req := httptest.NewRequest(http.MethodGet, "/", nil)
430 e.ServeHTTP(rec, req)
431 body := rec.Body.String()
432 assert.Equal(t, "{\"message\":\"method could not select target\"}\n", body)
433}
434
435func TestRandomBalancerWithNoTargets(t *testing.T) {
436 e := echo.New()

Callers

nothing calls this directly

Calls 4

ProxyFunction · 0.85
ServeHTTPMethod · 0.80
UseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…