Skip to content

Commit a7ee3d3

Browse files
committed
fix: flaky test
1 parent 07dfb6e commit a7ee3d3

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎.version‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.1070
1+
0.3.1071

‎cmd/templ/generatecmd/proxy/proxy_test.go‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,10 @@ func TestProxy(t *testing.T) {
490490
t.Errorf("expected Content-Length to be cleared for streaming, got %q", got)
491491
}
492492

493-
// Read the response body as it comes in, and look for at least one gap of >streamingGap between tokens.
493+
// Read the response body as it comes in, and look for at least one gap between tokens.
494+
// The measured gap is shorter than streamingGap, because the writer starts sleeping while
495+
// the reader is still tokenizing the first chunk, so the threshold allows for that.
496+
minGap := streamingGap / 2
494497
lastTime := time.Now()
495498
largestGap := time.Duration(0)
496499
sBB := &strings.Builder{}
@@ -518,8 +521,8 @@ func TestProxy(t *testing.T) {
518521
if diff := cmp.Diff(expectedString, sBB.String()); diff != "" {
519522
t.Errorf("unexpected response body (-got +want):\n%s", diff)
520523
}
521-
if largestGap < streamingGap {
522-
t.Errorf("expected at least one gap of >%v between tokens, got largest gap of %v", streamingGap, largestGap)
524+
if largestGap < minGap {
525+
t.Errorf("expected at least one gap of >%v between tokens, got largest gap of %v", minGap, largestGap)
523526
}
524527

525528
if writerErr1 != nil {

0 commit comments

Comments
 (0)