MCPcopy Index your code
hub / github.com/php/frankenphp / testConnectionAbort

Function testConnectionAbort

frankenphp_test.go:535–558  ·  view source on GitHub ↗
(t *testing.T, opts *testOptions)

Source from the content-addressed store, hash-verified

533 testConnectionAbort(t, &testOptions{workerScript: "connection_status.php"})
534}
535func testConnectionAbort(t *testing.T, opts *testOptions) {
536 testFinish := func(finish string) {
537 t.Run(fmt.Sprintf("finish=%s", finish), func(t *testing.T) {
538 var buf syncBuffer
539 opts.logger = slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelInfo}))
540
541 runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {
542 req := httptest.NewRequest("GET", fmt.Sprintf("http://example.com/connection_status.php?i=%d&finish=%s", i, finish), nil)
543 w := httptest.NewRecorder()
544
545 ctx, cancel := context.WithCancel(req.Context())
546 req = req.WithContext(ctx)
547 cancel()
548 handler(w, req)
549
550 for !strings.Contains(buf.String(), fmt.Sprintf("request %d: 1", i)) {
551 }
552 }, opts)
553 })
554 }
555
556 testFinish("0")
557 testFinish("1")
558}
559
560func TestException_module(t *testing.T) { testException(t, &testOptions{}) }
561func TestException_worker(t *testing.T) {

Callers 2

Calls 2

StringMethod · 0.95
runTestFunction · 0.85

Tested by

no test coverage detected