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

Function TestKeepRunningOnConnectionAbort

worker_test.go:159–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

157}
158
159func TestKeepRunningOnConnectionAbort(t *testing.T) {
160 runTest(t, func(handler func(http.ResponseWriter, *http.Request), _ *httptest.Server, i int) {
161 req := httptest.NewRequest("GET", "http://example.com/worker-with-counter.php", nil)
162
163 ctx, cancel := context.WithCancel(req.Context())
164 req = req.WithContext(ctx)
165 cancel()
166 body1, _ := testRequest(req, handler, t)
167
168 assert.Equal(t, "requests:1", body1, "should have handled exactly one request")
169 body2, _ := testGet("http://example.com/worker-with-counter.php", handler, t)
170
171 assert.Equal(t, "requests:2", body2, "should not have stopped execution after the first request was aborted")
172 }, &testOptions{workerScript: "worker-with-counter.php", nbWorkers: 1, nbParallelRequests: 1})
173}
174
175// TestWorkerMaxRequests verifies that a worker restarts after reaching max_requests.
176func TestWorkerMaxRequests(t *testing.T) {

Callers

nothing calls this directly

Calls 3

runTestFunction · 0.85
testRequestFunction · 0.85
testGetFunction · 0.85

Tested by

no test coverage detected