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

Function TestReadPacketWrongSequenceID

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

Source from the content-addressed store, hash-verified

132}
133
134func TestReadPacketWrongSequenceID(t *testing.T) {
135 for _, testCase := range []struct {
136 ClientSequenceID byte
137 ServerSequenceID byte
138 ExpectedErr error
139 }{
140 {
141 ClientSequenceID: 1,
142 ServerSequenceID: 0,
143 ExpectedErr: ErrPktSync,
144 },
145 {
146 ClientSequenceID: 0,
147 ServerSequenceID: 0x42,
148 ExpectedErr: ErrPktSync,
149 },
150 } {
151 conn, mc := newRWMockConn(testCase.ClientSequenceID)
152
153 conn.data = []byte{0x01, 0x00, 0x00, testCase.ServerSequenceID, 0x22}
154 _, err := mc.readPacket()
155 if err != testCase.ExpectedErr {
156 t.Errorf("expected %v, got %v", testCase.ExpectedErr, err)
157 }
158
159 // connection should not be returned to the pool in this state
160 if mc.IsValid() {
161 t.Errorf("expected IsValid() to be false")
162 }
163 }
164}
165
166func TestReadPacketSplit(t *testing.T) {
167 conn := new(mockConn)

Callers

nothing calls this directly

Calls 3

newRWMockConnFunction · 0.85
readPacketMethod · 0.80
IsValidMethod · 0.80

Tested by

no test coverage detected