MCPcopy Create free account
hub / github.com/datastax/cql-proxy / TestPartialExecuteCodec_Decode

Function TestPartialExecuteCodec_Decode

codecs/partial_codecs_test.go:153–180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestPartialExecuteCodec_Decode(t *testing.T) {
154 localSerialConsistency := primitive.ConsistencyLevelLocalSerial
155 codec := &partialExecuteCodec{}
156
157 msg := &message.Execute{
158 QueryId: []byte{0x0a, 0x0b, 0x0c},
159 ResultMetadataId: []byte{0x0d, 0x0e, 0x0f},
160 Options: &message.QueryOptions{
161 Consistency: primitive.ConsistencyLevelOne,
162 SerialConsistency: &localSerialConsistency,
163 },
164 }
165
166 var buf bytes.Buffer
167 err := builtinExecuteCodec.Encode(msg, &buf, primitive.ProtocolVersion4)
168 require.NoError(t, err)
169
170 execute, err := codec.Decode(NewFrameBodyReader(buf.Bytes()), primitive.ProtocolVersion4)
171 require.NoError(t, err)
172
173 assert.False(t, execute.IsResponse())
174 assert.Equal(t, primitive.OpCodeExecute, execute.GetOpCode())
175 assert.Equal(t, "EXECUTE 0a0b0c", execute.(*PartialExecute).String())
176
177 assert.Equal(t, []byte{0x0a, 0x0b, 0x0c}, execute.(*PartialExecute).QueryId)
178 assert.Equal(t, primitive.ConsistencyLevelOne, execute.(*PartialExecute).Consistency)
179 assert.Equal(t, []byte{0x10, 0x00, 0x9}, execute.(*PartialExecute).Parameters)
180}
181
182func TestPartialExecuteCodec_Decode_Invalid(t *testing.T) {
183 tests := []struct {

Callers

nothing calls this directly

Calls 6

DecodeMethod · 0.95
NewFrameBodyReaderFunction · 0.85
EncodeMethod · 0.45
IsResponseMethod · 0.45
GetOpCodeMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected