MCPcopy
hub / github.com/cloudflare/cloudflared / TestProxySSEAllData

Function TestProxySSEAllData

proxy/proxy_test.go:293–304  ·  view source on GitHub ↗

Regression test to guarantee that we always write the contents downstream even if EOF is reached without hitting the delimiter

(t *testing.T)

Source from the content-addressed store, hash-verified

291// Regression test to guarantee that we always write the contents downstream even if EOF is reached without
292// hitting the delimiter
293func TestProxySSEAllData(t *testing.T) {
294 eyeballReader := io.NopCloser(strings.NewReader("data\r\r"))
295 responseWriter := newMockSSERespWriter()
296
297 // responseWriter uses an unbuffered channel, so we call in a different go-routine
298 go func() {
299 _, _ = cfio.Copy(responseWriter, eyeballReader)
300 }()
301
302 result := string(<-responseWriter.writeNotification)
303 require.Equal(t, "data\r\r", result)
304}
305
306func TestProxyMultipleOrigins(t *testing.T) {
307 api := httptest.NewServer(mockAPI{})

Callers

nothing calls this directly

Calls 3

CopyFunction · 0.92
newMockSSERespWriterFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected