Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcd1429

Browse files
committed
chore: get all tests passing
1 parent792aa2d commitbcd1429

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

‎coderd/httpapi/httpapi_test.go

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,47 @@ func TestServerSentEventSender(t *testing.T) {
549549
require.True(t,<-successC)
550550
})
551551

552-
t.Run("Cancels the entire connection if the request context cancels",func(t*testing.T) {
553-
t.FailNow()
554-
t.Parallel()
555-
})
556-
557552
t.Run("Sends a heartbeat to the client on a fixed internal of time to keep connections alive",func(t*testing.T) {
558-
t.FailNow()
559553
t.Parallel()
554+
555+
// Need add at least three heartbeats for something to be reliably
556+
// counted as an interval, but also need some wiggle room
557+
heartbeatCount:=3
558+
hbDuration:=time.Duration(heartbeatCount)*httpapi.HeartbeatInterval
559+
timeout:=hbDuration+ (5*time.Second)
560+
561+
ctx:=testutil.Context(t,timeout)
562+
req:=newBaseRequest(ctx)
563+
writer:=newServerSentWriter(t)
564+
_,_,err:=httpapi.ServerSentEventSender(writer,req)
565+
require.NoError(t,err)
566+
567+
typeResultstruct {
568+
Errerror
569+
Successbool
570+
}
571+
resultC:=make(chanResult)
572+
gofunc() {
573+
err:=writer.
574+
clientConn.
575+
SetReadDeadline(time.Now().Add(timeout))
576+
iferr!=nil {
577+
resultC<-Result{err,false}
578+
return
579+
}
580+
forrangeheartbeatCount {
581+
pingBuffer:=make([]byte,1)
582+
pingSize,err:=writer.clientConn.Read(pingBuffer)
583+
iferr!=nil||pingSize!=1 {
584+
resultC<-Result{err,false}
585+
return
586+
}
587+
}
588+
resultC<-Result{nil,true}
589+
}()
590+
591+
result:=<-resultC
592+
require.NoError(t,result.Err)
593+
require.True(t,result.Success)
560594
})
561595
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp