MCPcopy Create free account
hub / github.com/zalando/skipper / TestFlusherImplementation

Function TestFlusherImplementation

proxy/proxy_test.go:1268–1304  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1266}
1267
1268func TestFlusherImplementation(t *testing.T) {
1269 h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1270 w.Write([]byte("Hello, "))
1271 time.Sleep(15 * time.Millisecond)
1272 w.Write([]byte("world!"))
1273 })
1274
1275 ts := httptest.NewServer(h)
1276 defer ts.Close()
1277
1278 doc := fmt.Sprintf(`* -> "%s"`, ts.URL)
1279 tp, err := newTestProxy(doc, FlagsNone)
1280 if err != nil {
1281 t.Error(err)
1282 return
1283 }
1284 defer tp.close()
1285
1286 ps := httptest.NewServer(tp.proxy)
1287 defer ps.Close()
1288
1289 rsp, err := http.Get(ps.URL)
1290 if err != nil {
1291 t.Error(err)
1292 return
1293 }
1294 defer rsp.Body.Close()
1295
1296 b, err := io.ReadAll(rsp.Body)
1297 if err != nil {
1298 t.Error(err)
1299 return
1300 }
1301 if string(b) != "Hello, world!" {
1302 t.Error("failed to receive response")
1303 }
1304}
1305
1306func TestOriginalRequestResponse(t *testing.T) {
1307 s := startTestServer(nil, 0, func(r *http.Request) {

Callers

nothing calls this directly

Calls 6

newTestProxyFunction · 0.85
CloseMethod · 0.65
ErrorMethod · 0.65
GetMethod · 0.65
WriteMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…