MCPcopy
hub / github.com/segmentio/kafka-go / testConnWriteReadSequentially

Function testConnWriteReadSequentially

conn_test.go:500–522  ·  view source on GitHub ↗
(t *testing.T, conn *Conn)

Source from the content-addressed store, hash-verified

498}
499
500func testConnWriteReadSequentially(t *testing.T, conn *Conn) {
501 for i := 0; i != 10; i++ {
502 if _, err := conn.Write([]byte(strconv.Itoa(i))); err != nil {
503 t.Fatal(err)
504 }
505 }
506
507 b := make([]byte, 128)
508
509 for i := 0; i != 10; i++ {
510 n, err := conn.Read(b)
511 if err != nil {
512 t.Error(err)
513 continue
514 }
515 s := string(b[:n])
516 if v, err := strconv.Atoi(s); err != nil {
517 t.Error(err)
518 } else if v != i {
519 t.Errorf("bad message read at offset %d: %s", i, s)
520 }
521 }
522}
523
524func testConnWriteBatchReadSequentially(t *testing.T, conn *Conn) {
525 msgs := makeTestSequence(10)

Callers

nothing calls this directly

Calls 3

WriteMethod · 0.45
ReadMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected