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

Function TestPartialExecuteCodec_Encode

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

Source from the content-addressed store, hash-verified

215}
216
217func TestPartialExecuteCodec_Encode(t *testing.T) {
218 tests := []struct {
219 name string
220 msg *message.Execute
221 }{
222 {
223 name: "simple",
224 msg: &message.Execute{
225 QueryId: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8},
226 ResultMetadataId: []byte{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0xa, 0xb},
227 },
228 },
229 {
230 name: "consistency",
231 msg: &message.Execute{
232 QueryId: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8},
233 ResultMetadataId: []byte{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0xa, 0xb},
234 Options: &message.QueryOptions{
235 Consistency: primitive.ConsistencyLevelEachQuorum,
236 },
237 },
238 },
239 {
240 name: "parameters",
241 msg: &message.Execute{
242 QueryId: []byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8},
243 ResultMetadataId: []byte{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0xa, 0xb},
244 Options: &message.QueryOptions{
245 Consistency: primitive.ConsistencyLevelEachQuorum,
246 PositionalValues: []*primitive.Value{
247 {
248 Type: primitive.ValueTypeRegular,
249 Contents: []byte{0x1, 0x2, 0x3},
250 },
251 {
252 Type: primitive.ValueTypeRegular,
253 Contents: []byte{0x4, 0x5, 0x6},
254 },
255 },
256 SkipMetadata: true,
257 PageSize: 123,
258 PageSizeInBytes: false,
259 PagingState: []byte{0xa, 0xb, 0xc},
260 Keyspace: "keyspace1",
261 },
262 },
263 },
264 }
265
266 codec := &partialExecuteCodec{}
267 version := primitive.ProtocolVersion4
268
269 for _, tt := range tests {
270 t.Run(tt.name, func(t *testing.T) {
271 expectedLen, err := builtinExecuteCodec.EncodedLength(tt.msg, version)
272 assert.NoError(t, err, "unexpected error calculating encoded length with built-in execute codec")
273
274 var expectedBytes bytes.Buffer

Callers

nothing calls this directly

Calls 6

DecodeMethod · 0.95
EncodedLengthMethod · 0.95
EncodeMethod · 0.95
NewFrameBodyReaderFunction · 0.85
EncodedLengthMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected