Skip to content

Commit 4851988

Browse files
committed
run_blocking replaces run_sync
1 parent c69133d commit 4851988

4 files changed

Lines changed: 21 additions & 125 deletions

File tree

test/unit/run_sync.hpp

Lines changed: 0 additions & 108 deletions
This file was deleted.

test/unit/server/flat_router.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <boost/http/server/router.hpp>
1616

17-
#include "run_sync.hpp"
17+
#include <boost/capy/test/run_blocking.hpp>
1818
#include "test_suite.hpp"
1919

2020
namespace boost {
@@ -39,11 +39,11 @@ struct flat_router_test
3939
flat_router fr2(fr1);
4040

4141
params req;
42-
run_sync()(fr1.dispatch(
42+
capy::test::run_blocking()(fr1.dispatch(
4343
http::method::get, urls::url_view("/"), req));
4444
BOOST_TEST_EQ(*counter, 1);
4545

46-
run_sync()(fr2.dispatch(
46+
capy::test::run_blocking()(fr2.dispatch(
4747
http::method::get, urls::url_view("/"), req));
4848
BOOST_TEST_EQ(*counter, 2);
4949
}
@@ -70,11 +70,11 @@ struct flat_router_test
7070
fr2 = fr1;
7171

7272
params req;
73-
run_sync()(fr1.dispatch(
73+
capy::test::run_blocking()(fr1.dispatch(
7474
http::method::get, urls::url_view("/"), req));
7575
BOOST_TEST_EQ(*counter, 1);
7676

77-
run_sync()(fr2.dispatch(
77+
capy::test::run_blocking()(fr2.dispatch(
7878
http::method::get, urls::url_view("/"), req));
7979
BOOST_TEST_EQ(*counter, 2);
8080
}

test/unit/server/route_handler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <boost/http/server/flat_router.hpp>
1515
#include <boost/http/request.hpp>
1616

17-
#include "run_sync.hpp"
17+
#include <boost/capy/test/run_blocking.hpp>
1818
#include "test_route_handler.hpp"
1919
#include "test_suite.hpp"
2020

@@ -40,8 +40,9 @@ struct route_handler_test
4040
{
4141
flat_router fr(std::move(r));
4242
test_route_params p;
43-
auto rv = run_sync()(fr.dispatch(
44-
verb, urls::url_view(url), p));
43+
route_result rv;
44+
capy::test::run_blocking([&](route_result r) { rv = r; })(
45+
fr.dispatch(verb, urls::url_view(url), p));
4546
if(BOOST_TEST_EQ(rv.message(), rv0.message()))
4647
BOOST_TEST(rv == rv0);
4748
}

test/unit/server/router.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <boost/http/server/flat_router.hpp>
1313
#include <boost/http/server/detail/router_base.hpp>
1414

15-
#include "run_sync.hpp"
15+
#include <boost/capy/test/run_blocking.hpp>
1616
#include "test_suite.hpp"
1717

1818
namespace boost {
@@ -107,8 +107,9 @@ struct router_test
107107
{
108108
flat_router fr(std::move(r));
109109
params req;
110-
auto rv = run_sync()(fr.dispatch(
111-
http::method::get, urls::url_view(url), req));
110+
route_result rv;
111+
capy::test::run_blocking([&](route_result res) { rv = res; })(
112+
fr.dispatch(http::method::get, urls::url_view(url), req));
112113
BOOST_TEST_EQ(rv.message(), rv0.message());
113114
}
114115

@@ -120,8 +121,9 @@ struct router_test
120121
{
121122
flat_router fr(std::move(r));
122123
params req;
123-
auto rv = run_sync()(fr.dispatch(
124-
verb, urls::url_view(url), req));
124+
route_result rv;
125+
capy::test::run_blocking([&](route_result res) { rv = res; })(
126+
fr.dispatch(verb, urls::url_view(url), req));
125127
BOOST_TEST_EQ(rv.message(), rv0.message());
126128
}
127129

@@ -133,8 +135,9 @@ struct router_test
133135
{
134136
flat_router fr(std::move(r));
135137
params req;
136-
auto rv = run_sync()(fr.dispatch(
137-
verb, urls::url_view(url), req));
138+
route_result rv;
139+
capy::test::run_blocking([&](route_result res) { rv = res; })(
140+
fr.dispatch(verb, urls::url_view(url), req));
138141
BOOST_TEST_EQ(rv.message(), rv0.message());
139142
}
140143

@@ -410,7 +413,7 @@ struct router_test
410413
flat_router fr(std::move(r));
411414
params req;
412415
BOOST_TEST_THROWS(
413-
run_sync()(fr.dispatch(
416+
capy::test::run_blocking()(fr.dispatch(
414417
http::method::unknown, urls::url_view("/"), req)),
415418
std::invalid_argument);
416419
}
@@ -422,7 +425,7 @@ struct router_test
422425
flat_router fr(std::move(r));
423426
params req;
424427
BOOST_TEST_THROWS(
425-
run_sync()(fr.dispatch(
428+
capy::test::run_blocking()(fr.dispatch(
426429
"", urls::url_view("/"), req)),
427430
std::invalid_argument);
428431
}

0 commit comments

Comments
 (0)