MCPcopy
hub / github.com/go-sql-driver/mysql / TestReadPacketSingleByte

Function TestReadPacketSingleByte

packets_test.go:112–132  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestReadPacketSingleByte(t *testing.T) {
113 conn := new(mockConn)
114 mc := &mysqlConn{
115 netConn: conn,
116 buf: newBuffer(),
117 cfg: NewConfig(),
118 }
119
120 conn.data = []byte{0x01, 0x00, 0x00, 0x00, 0xff}
121 conn.maxReads = 1
122 packet, err := mc.readPacket()
123 if err != nil {
124 t.Fatal(err)
125 }
126 if len(packet) != 1 {
127 t.Fatalf("unexpected packet length: expected %d, got %d", 1, len(packet))
128 }
129 if packet[0] != 0xff {
130 t.Fatalf("unexpected packet content: expected %x, got %x", 0xff, packet[0])
131 }
132}
133
134func TestReadPacketWrongSequenceID(t *testing.T) {
135 for _, testCase := range []struct {

Callers

nothing calls this directly

Calls 3

readPacketMethod · 0.95
newBufferFunction · 0.85
NewConfigFunction · 0.85

Tested by

no test coverage detected