#include "bolt_common.hpp" #include "communication/bolt/v1/encoder/chunked_buffer.hpp" #include "communication/bolt/v1/encoder/encoder.hpp" #include "communication/bolt/v1/encoder/result_stream.hpp" #include "query/backend/cpp/typed_value.hpp" using buffer_t = communication::bolt::ChunkedBuffer; using encoder_t = communication::bolt::Encoder; using result_stream_t = communication::bolt::ResultStream; const uint8_t header_output[] = "\x00\x29\xB1\x70\xA1\x86\x66\x69\x65\x6C\x64\x73\x9A\x82\x61\x61\x82\x62\x62\x82\x63\x63\x82\x64\x64\x82\x65\x65\x82\x66\x66\x82\x67\x67\x82\x68\x68\x82\x69\x69\x82\x6A\x6A\x00\x00"; const uint8_t result_output[] = "\x00\x0A\xB1\x71\x92\x05\x85\x68\x65\x6C\x6C\x6F\x00\x00"; const uint8_t summary_output[] = "\x00\x0C\xB1\x70\xA1\x87\x63\x68\x61\x6E\x67\x65\x64\x0A\x00\x00"; TEST(Bolt, ResultStream) { TestSocket socket(10); encoder_t encoder(socket); result_stream_t result_stream(encoder); std::vector& output = socket.output; std::vector headers; for (int i = 0; i < 10; ++i) headers.push_back(std::string(2, (char)('a' + i))); result_stream.Header(headers); print_output(output); check_output(output, header_output, 45); std::vector result{TypedValue(5), TypedValue(std::string("hello"))}; result_stream.Result(result); print_output(output); check_output(output, result_output, 14); std::map summary; summary.insert(std::make_pair(std::string("changed"), TypedValue(10))); result_stream.Summary(summary); print_output(output); check_output(output, summary_output, 16); } int main(int argc, char** argv) { logging::init_sync(); logging::log->pipe(std::make_unique()); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }