Skip to content

Commit 585988b

Browse files
committed
Test for connection::async_exec
1 parent b5e90ea commit 585988b

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

include/boost/redis/adapter/any_adapter.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class any_adapter
4949
} impl_;
5050

5151
template <class T>
52-
static auto create_impl(T& response) -> impl_t
52+
static auto create_impl(T& resp) -> impl_t
5353
{
5454
using namespace boost::redis::adapter;
55-
auto adapter = boost_redis_adapt(response);
55+
auto adapter = boost_redis_adapt(resp);
5656
std::size_t size = adapter.get_supported_response_size();
5757
return { std::move(adapter), size };
5858
}

test/test_conn_exec.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
* accompanying file LICENSE.txt)
55
*/
66

7+
#include <boost/redis/adapter/any_adapter.hpp>
78
#include <boost/redis/connection.hpp>
89
#include <boost/system/errc.hpp>
910
#include <boost/asio/detached.hpp>
11+
#include <string>
1012
#define BOOST_TEST_MODULE conn-exec
1113
#include <boost/test/included/unit_test.hpp>
1214
#include <iostream>
@@ -188,3 +190,25 @@ BOOST_AUTO_TEST_CASE(large_number_of_concurrent_requests_issue_170)
188190
BOOST_CHECK_EQUAL(counter, repeat);
189191
}
190192

193+
BOOST_AUTO_TEST_CASE(exec_any_response)
194+
{
195+
// Executing an any_response object works
196+
request req;
197+
req.push("PING", "PONG");
198+
response<std::string> res;
199+
200+
net::io_context ioc;
201+
202+
auto conn = std::make_shared<connection>(ioc);
203+
204+
conn->async_exec(req, boost::redis::any_adapter(res), [&](auto ec, auto){
205+
BOOST_TEST(!ec);
206+
conn->cancel();
207+
});
208+
209+
run(conn);
210+
ioc.run();
211+
212+
BOOST_TEST(std::get<0>(res).value() == "PONG");
213+
}
214+

0 commit comments

Comments
 (0)