(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestPartialQueryCodec_Encode(t *testing.T) { |
| 73 | tests := []struct { |
| 74 | name string |
| 75 | msg *message.Query |
| 76 | }{ |
| 77 | { |
| 78 | name: "simple", |
| 79 | msg: &message.Query{ |
| 80 | Query: "select * from table1", |
| 81 | }, |
| 82 | }, |
| 83 | { |
| 84 | name: "consistency", |
| 85 | msg: &message.Query{ |
| 86 | Query: "select * from table2", |
| 87 | Options: &message.QueryOptions{ |
| 88 | Consistency: primitive.ConsistencyLevelEachQuorum, |
| 89 | }, |
| 90 | }, |
| 91 | }, |
| 92 | { |
| 93 | name: "parameters", |
| 94 | msg: &message.Query{ |
| 95 | Query: "select * from table2", |
| 96 | Options: &message.QueryOptions{ |
| 97 | Consistency: primitive.ConsistencyLevelEachQuorum, |
| 98 | PositionalValues: []*primitive.Value{ |
| 99 | { |
| 100 | Type: primitive.ValueTypeRegular, |
| 101 | Contents: []byte{0x1, 0x2, 0x3}, |
| 102 | }, |
| 103 | { |
| 104 | Type: primitive.ValueTypeRegular, |
| 105 | Contents: []byte{0x4, 0x5, 0x6}, |
| 106 | }, |
| 107 | }, |
| 108 | SkipMetadata: true, |
| 109 | PageSize: 123, |
| 110 | PageSizeInBytes: false, |
| 111 | PagingState: []byte{0xa, 0xb, 0xc}, |
| 112 | Keyspace: "keyspace1", |
| 113 | }, |
| 114 | }, |
| 115 | }, |
| 116 | } |
| 117 | |
| 118 | codec := &partialQueryCodec{} |
| 119 | version := primitive.ProtocolVersion4 |
| 120 | |
| 121 | for _, tt := range tests { |
| 122 | t.Run(tt.name, func(t *testing.T) { |
| 123 | expectedLen, err := builtinQueryCodec.EncodedLength(tt.msg, version) |
| 124 | assert.NoError(t, err, "unexpected error calculating encoded length with built-in query codec") |
| 125 | |
| 126 | var expectedBytes bytes.Buffer |
| 127 | err = builtinQueryCodec.Encode(tt.msg, &expectedBytes, version) |
| 128 | require.NoError(t, err, "unexpected error encoding with built-in query codec") |
| 129 |
nothing calls this directly
no test coverage detected