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

Function TestTargetProvider

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

Source from the content-addressed store, hash-verified

398}
399
400func TestTargetProvider(t *testing.T) {
401 t1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
402 fmt.Fprint(w, "target 1")
403 }))
404 defer t1.Close()
405 url1, _ := url.Parse(t1.URL)
406
407 e := echo.New()
408 tp := &testProvider{}
409 tp.target = &ProxyTarget{Name: "target 1", URL: url1}
410 e.Use(Proxy(tp))
411 rec := httptest.NewRecorder()
412 req := httptest.NewRequest(http.MethodGet, "/", nil)
413 e.ServeHTTP(rec, req)
414 body := rec.Body.String()
415 assert.Equal(t, "target 1", body)
416}
417
418func TestFailNextTarget(t *testing.T) {
419 url1, err := url.Parse("http://dummy:8080")

Callers

nothing calls this directly

Calls 5

ProxyFunction · 0.85
ServeHTTPMethod · 0.80
CloseMethod · 0.45
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…