MCPcopy
hub / github.com/coder/websocket / newConnTest

Function newConnTest

conn_test.go:501–521  ·  view source on GitHub ↗
(t testing.TB, dialOpts *websocket.DialOptions, acceptOpts *websocket.AcceptOptions)

Source from the content-addressed store, hash-verified

499}
500
501func newConnTest(t testing.TB, dialOpts *websocket.DialOptions, acceptOpts *websocket.AcceptOptions) (tt *connTest, c1, c2 *websocket.Conn) {
502 if t, ok := t.(*testing.T); ok {
503 t.Parallel()
504 }
505 t.Helper()
506
507 ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
508 tt = &connTest{t: t, ctx: ctx}
509 t.Cleanup(cancel)
510
511 c1, c2 = wstest.Pipe(dialOpts, acceptOpts)
512 if xrand.Bool() {
513 c1, c2 = c2, c1
514 }
515 t.Cleanup(func() {
516 c2.CloseNow()
517 c1.CloseNow()
518 })
519
520 return tt, c1, c2
521}
522
523func (tt *connTest) goEchoLoop(c *websocket.Conn) {
524 ctx, cancel := context.WithCancel(tt.ctx)

Callers 3

TestConnFunction · 0.85
BenchmarkConnFunction · 0.85
TestConnClosePropagationFunction · 0.85

Calls 3

PipeFunction · 0.92
BoolFunction · 0.92
CloseNowMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…