(t *testing.T, opts *testOptions)
| 533 | testConnectionAbort(t, &testOptions{workerScript: "connection_status.php"}) |
| 534 | } |
| 535 | func 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 | |
| 560 | func TestException_module(t *testing.T) { testException(t, &testOptions{}) } |
| 561 | func TestException_worker(t *testing.T) { |
no test coverage detected