MCPcopy
hub / github.com/nats-io/nats.go / TestWSControlFrameBetweenDataFrames

Function TestWSControlFrameBetweenDataFrames

ws_test.go:389–417  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

387}
388
389func TestWSControlFrameBetweenDataFrames(t *testing.T) {
390 mr := &fakeReader{ch: make(chan []byte, 1)}
391 defer mr.close()
392 r := wsNewReader(mr)
393
394 p := make([]byte, 100)
395
396 // Write a frame that will continue after the PONG
397 mr.buf.Write([]byte{2, 3})
398 mr.buf.WriteString("ABC")
399 // Write a PONG
400 mr.buf.Write([]byte{138, 0})
401 // Continuation of the frame
402 mr.buf.Write([]byte{0, 3})
403 mr.buf.WriteString("DEF")
404 // Another PONG
405 mr.buf.Write([]byte{138, 0})
406 // End of frame
407 mr.buf.Write([]byte{128, 3})
408 mr.buf.WriteString("GHI")
409
410 n, err := r.Read(p)
411 if err != nil {
412 t.Fatalf("Error on read: %v", err)
413 }
414 if string(p[:n]) != "ABCDEFGHI" {
415 t.Fatalf("Unexpected result: %q", p[:n])
416 }
417}
418
419func TestWSDecompressor(t *testing.T) {
420 var br *wsDecompressor

Callers

nothing calls this directly

Calls 5

closeMethod · 0.95
wsNewReaderFunction · 0.85
FatalfMethod · 0.80
WriteMethod · 0.45
ReadMethod · 0.45

Tested by

no test coverage detected