Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add a test for reporting html first served
  • Loading branch information
hugodutka committed Jan 30, 2025
commit 35e79bcb571d68123c6b5fdb76e90c7daaa8b74f
22 changes: 21 additions & 1 deletion cli/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ func TestServer(t *testing.T) {
server := httptest.NewServer(r)
defer server.Close()

inv, _ := clitest.New(t,
inv, cfg := clitest.New(t,
"server",
"--in-memory",
"--http-address", ":0",
Expand All @@ -977,6 +977,26 @@ func TestServer(t *testing.T) {

<-deployment
<-snapshot

accessURL := waitAccessURL(t, cfg)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
ctx := testutil.Context(t, testutil.WaitMedium)

defer cancel()
client := codersdk.New(accessURL)
body, err := client.Request(ctx, http.MethodGet, "/", nil)
require.NoError(t, err)
require.NoError(t, body.Body.Close())

snap := <-snapshot
require.Condition(t, func() bool {
htmlFirstServedFound := false
for _, item := range snap.TelemetryItems {
if item.Key == string(telemetry.TelemetryItemKeyHTMLFirstServedAt) {
htmlFirstServedFound = true
}
}
return htmlFirstServedFound
}, "no html_first_served telemetry item")
})
t.Run("Prometheus", func(t *testing.T) {
t.Parallel()
Expand Down
Loading