(t *testing.T)
| 612 | } |
| 613 | |
| 614 | func TestServer_SSEMiddleware_Events(t *testing.T) { |
| 615 | t.Parallel() |
| 616 | ctx := logctx.WithLogger(context.Background(), slog.New(slog.NewTextHandler(os.Stdout, nil))) |
| 617 | srv, err := httpapi.NewServer(ctx, httpapi.ServerConfig{ |
| 618 | AgentType: msgfmt.AgentTypeClaude, |
| 619 | AgentIO: nil, |
| 620 | Port: 0, |
| 621 | ChatBasePath: "/chat", |
| 622 | AllowedHosts: []string{"*"}, |
| 623 | AllowedOrigins: []string{"*"}, |
| 624 | }) |
| 625 | require.NoError(t, err) |
| 626 | tsServer := httptest.NewServer(srv.Handler()) |
| 627 | t.Cleanup(tsServer.Close) |
| 628 | |
| 629 | t.Run("events", func(t *testing.T) { |
| 630 | t.Parallel() |
| 631 | resp, err := tsServer.Client().Get(tsServer.URL + "/events") |
| 632 | require.NoError(t, err) |
| 633 | t.Cleanup(func() { |
| 634 | _ = resp.Body.Close() |
| 635 | }) |
| 636 | assertSSEHeaders(t, resp) |
| 637 | }) |
| 638 | |
| 639 | t.Run("internal/screen", func(t *testing.T) { |
| 640 | t.Parallel() |
| 641 | |
| 642 | resp, err := tsServer.Client().Get(tsServer.URL + "/internal/screen") |
| 643 | require.NoError(t, err) |
| 644 | t.Cleanup(func() { |
| 645 | _ = resp.Body.Close() |
| 646 | }) |
| 647 | assertSSEHeaders(t, resp) |
| 648 | }) |
| 649 | } |
| 650 | |
| 651 | func assertSSEHeaders(t testing.TB, resp *http.Response) { |
| 652 | t.Helper() |
nothing calls this directly
no test coverage detected