mirror of
https://github.com/boostorg/mysql.git
synced 2026-02-15 01:02:17 +00:00
Reduced integ test overparametrize
This commit is contained in:
@@ -13,9 +13,13 @@
|
||||
using namespace boost::mysql::test;
|
||||
using boost::mysql::error_code;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"});
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_close_connection)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(active_connection, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(active_connection, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
@@ -35,7 +39,7 @@ BOOST_MYSQL_NETWORK_TEST(active_connection, network_fixture)
|
||||
BOOST_TEST(!conn->is_open());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(not_open_connection, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(not_open_connection, network_fixture, net_samples)
|
||||
{
|
||||
setup(sample.net);
|
||||
conn->close().validate_no_error();
|
||||
@@ -43,3 +47,5 @@ BOOST_MYSQL_NETWORK_TEST(not_open_connection, network_fixture)
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // test_close_connection
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -11,9 +11,11 @@ using namespace boost::mysql::test;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"});
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_close_statement)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(success, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(success, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
|
||||
@@ -13,12 +13,16 @@ using boost::mysql::error_code;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples = create_network_samples(
|
||||
{"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"}
|
||||
);
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_connect)
|
||||
|
||||
// The OK case is already being tested by all other integ tests
|
||||
// that require the connection to be connected
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(physical_error, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(physical_error, network_fixture, net_samples)
|
||||
{
|
||||
setup(sample.net);
|
||||
|
||||
@@ -28,7 +32,7 @@ BOOST_MYSQL_NETWORK_TEST(physical_error, network_fixture)
|
||||
BOOST_TEST(!conn->is_open());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(physical_ok_handshake_error, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(physical_ok_handshake_error, network_fixture, net_samples)
|
||||
{
|
||||
setup(sample.net);
|
||||
set_credentials("integ_user", "bad_password");
|
||||
|
||||
@@ -25,10 +25,14 @@ using boost::mysql::make_execute_params;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples = create_network_samples(
|
||||
{"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"}
|
||||
);
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_execute_statement)
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(iterator)
|
||||
BOOST_MYSQL_NETWORK_TEST(ok_no_params, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ok_no_params, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
@@ -41,7 +45,7 @@ BOOST_MYSQL_NETWORK_TEST(ok_no_params, network_fixture)
|
||||
BOOST_TEST(result->base().valid());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
@@ -55,7 +59,7 @@ BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture)
|
||||
BOOST_TEST(result->base().valid());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(mismatched_num_params, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(mismatched_num_params, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
@@ -69,7 +73,7 @@ BOOST_MYSQL_NETWORK_TEST(mismatched_num_params, network_fixture)
|
||||
.validate_error(errc::wrong_num_params, {"param", "2", "1", "statement", "execute"});
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(server_error, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(server_error, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
@@ -94,7 +98,7 @@ BOOST_AUTO_TEST_SUITE_END()
|
||||
// collection is a wrapper around execute_params, so only
|
||||
// a subset of tests are run here
|
||||
BOOST_AUTO_TEST_SUITE(collection)
|
||||
BOOST_MYSQL_NETWORK_TEST(ok, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ok, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
@@ -107,7 +111,7 @@ BOOST_MYSQL_NETWORK_TEST(ok, network_fixture)
|
||||
BOOST_TEST(result->base().valid());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(error, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(error, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
|
||||
@@ -34,6 +34,27 @@ using boost::mysql::tcp_ssl_resultset;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples_ssl = create_network_samples(
|
||||
{"tcp_ssl_sync_errc",
|
||||
"tcp_ssl_sync_exc",
|
||||
"tcp_ssl_async_callback",
|
||||
"tcp_ssl_async_callback_noerrinfo"}
|
||||
);
|
||||
|
||||
auto net_samples_nossl = create_network_samples(
|
||||
{"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"}
|
||||
);
|
||||
|
||||
// Subset of plaintext variants, to reduce test runtime
|
||||
auto net_samples_all = create_network_samples(
|
||||
{"tcp_ssl_sync_errc",
|
||||
"tcp_ssl_sync_exc",
|
||||
"tcp_ssl_async_callback",
|
||||
"tcp_ssl_async_callback_noerrinfo",
|
||||
"tcp_sync_errc",
|
||||
"tcp_async_callback"}
|
||||
);
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_handshake)
|
||||
|
||||
struct handshake_fixture : network_fixture
|
||||
@@ -68,21 +89,21 @@ struct handshake_fixture : network_fixture
|
||||
// mysql_native_password
|
||||
BOOST_AUTO_TEST_SUITE(mysql_native_password)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(regular_user, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(regular_user, handshake_fixture, net_samples_all)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
set_credentials("mysqlnp_user", "mysqlnp_password");
|
||||
do_handshake_ok();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(empty_password, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(empty_password, handshake_fixture, net_samples_all)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
set_credentials("mysqlnp_empty_password_user", "");
|
||||
do_handshake_ok();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(bad_password, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(bad_password, handshake_fixture, net_samples_all)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
set_credentials("mysqlnp_user", "bad_password");
|
||||
@@ -120,7 +141,7 @@ struct caching_sha2_fixture : handshake_fixture
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(ssl_on_cache_hit, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_on_cache_hit, caching_sha2_fixture, net_samples_ssl)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
set_credentials("csha2p_user", "csha2p_password");
|
||||
@@ -128,7 +149,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(ssl_on_cache_hit, caching_sha2_fixture)
|
||||
do_handshake_ok_ssl();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_hit, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_hit, caching_sha2_fixture, net_samples_all)
|
||||
{
|
||||
// As we are sending password hashed, it is OK to not have SSL for this
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -137,7 +158,7 @@ BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_hit, caching_sha2_fixture)
|
||||
do_handshake_ok_nossl();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(ssl_on_cache_miss, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_on_cache_miss, caching_sha2_fixture, net_samples_ssl)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
set_credentials("csha2p_user", "csha2p_password");
|
||||
@@ -145,7 +166,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(ssl_on_cache_miss, caching_sha2_fixture)
|
||||
do_handshake_ok_ssl();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_miss, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_miss, caching_sha2_fixture, net_samples_all)
|
||||
{
|
||||
// A cache miss would force us send a plaintext password over
|
||||
// a non-TLS connection, so we fail
|
||||
@@ -156,7 +177,7 @@ BOOST_MYSQL_NETWORK_TEST(ssl_off_cache_miss, caching_sha2_fixture)
|
||||
conn->handshake(params).validate_error(errc::auth_plugin_requires_ssl, {});
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(empty_password_ssl_on_cache_hit, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_on_cache_hit, caching_sha2_fixture, net_samples_ssl)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
set_credentials("csha2p_empty_password_user", "");
|
||||
@@ -164,7 +185,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(empty_password_ssl_on_cache_hit, caching_sha2_fixtu
|
||||
do_handshake_ok_ssl();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_hit, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_hit, caching_sha2_fixture, net_samples_all)
|
||||
{
|
||||
// Empty passwords are allowed over non-TLS connections
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -173,7 +194,7 @@ BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_hit, caching_sha2_fixture)
|
||||
do_handshake_ok_nossl();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(empty_password_ssl_on_cache_miss, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_on_cache_miss, caching_sha2_fixture, net_samples_ssl)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
set_credentials("csha2p_empty_password_user", "");
|
||||
@@ -181,7 +202,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(empty_password_ssl_on_cache_miss, caching_sha2_fixt
|
||||
do_handshake_ok_ssl();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_miss, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_miss, caching_sha2_fixture, net_samples_all)
|
||||
{
|
||||
// Empty passwords are allowed over non-TLS connections
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -190,7 +211,7 @@ BOOST_MYSQL_NETWORK_TEST(empty_password_ssl_off_cache_miss, caching_sha2_fixture
|
||||
do_handshake_ok_nossl();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(bad_password_ssl_on_cache_hit, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(bad_password_ssl_on_cache_hit, caching_sha2_fixture, net_samples_ssl)
|
||||
{
|
||||
// Note: test over non-TLS would return "ssl required"
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -202,7 +223,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(bad_password_ssl_on_cache_hit, caching_sha2_fixture
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(bad_password_ssl_on_cache_miss, caching_sha2_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(bad_password_ssl_on_cache_miss, caching_sha2_fixture, net_samples_ssl)
|
||||
{
|
||||
// Note: test over non-TLS would return "ssl required"
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -243,7 +264,7 @@ OzBrmpfHEhF6NDU=
|
||||
-----END CERTIFICATE-----
|
||||
)%";
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(certificate_valid, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(certificate_valid, handshake_fixture, net_samples_ssl)
|
||||
{
|
||||
// Context changes need to be before setup
|
||||
ssl_ctx.set_verify_mode(boost::asio::ssl::verify_peer);
|
||||
@@ -252,7 +273,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(certificate_valid, handshake_fixture)
|
||||
do_handshake_ok_ssl();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(certificate_invalid, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(certificate_invalid, handshake_fixture, net_samples_ssl)
|
||||
{
|
||||
ssl_ctx.set_verify_mode(boost::asio::ssl::verify_peer);
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -260,7 +281,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(certificate_invalid, handshake_fixture)
|
||||
BOOST_TEST(result.err.message().find("certificate verify failed") != std::string::npos);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(custom_certificate_verification_failed, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(custom_certificate_verification_failed, handshake_fixture, net_samples_ssl)
|
||||
{
|
||||
ssl_ctx.set_verify_mode(boost::asio::ssl::verify_peer);
|
||||
ssl_ctx.add_certificate_authority(boost::asio::buffer(CA_PEM));
|
||||
@@ -270,7 +291,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(custom_certificate_verification_failed, handshake_f
|
||||
BOOST_TEST(result.err.message().find("certificate verify failed") != std::string::npos);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(custom_certificate_verification_ok, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(custom_certificate_verification_ok, handshake_fixture, net_samples_ssl)
|
||||
{
|
||||
ssl_ctx.set_verify_mode(boost::asio::ssl::verify_peer);
|
||||
ssl_ctx.add_certificate_authority(boost::asio::buffer(CA_PEM));
|
||||
@@ -282,14 +303,14 @@ BOOST_MYSQL_NETWORK_TEST_SSL(custom_certificate_verification_ok, handshake_fixtu
|
||||
BOOST_AUTO_TEST_SUITE_END() // ssl_certificate_validation
|
||||
|
||||
// Other handshake tests
|
||||
BOOST_MYSQL_NETWORK_TEST(no_database, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(no_database, handshake_fixture, net_samples_all)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
params.set_database("");
|
||||
do_handshake_ok();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(bad_database, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(bad_database, handshake_fixture, net_samples_all)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
params.set_database("bad_database");
|
||||
@@ -300,7 +321,7 @@ BOOST_MYSQL_NETWORK_TEST(bad_database, handshake_fixture)
|
||||
}
|
||||
|
||||
BOOST_TEST_DECORATOR(*boost::unit_test::label("sha256"))
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(unknown_auth_plugin, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(unknown_auth_plugin, handshake_fixture, net_samples_ssl)
|
||||
{
|
||||
// Note: sha256_password is not supported, so it's an unknown plugin to us
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -308,7 +329,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(unknown_auth_plugin, handshake_fixture)
|
||||
conn->handshake(params).validate_error(errc::unknown_auth_plugin, {});
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(bad_user, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(bad_user, handshake_fixture, net_samples_nossl)
|
||||
{
|
||||
// unreliable without SSL. If the default plugin requires SSL
|
||||
// (like SHA256), this would fail with 'ssl required'
|
||||
@@ -317,7 +338,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(bad_user, handshake_fixture)
|
||||
conn->handshake(params).validate_any_error(); // may be access denied or unknown auth plugin
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_disable, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_disable, handshake_fixture, net_samples_all)
|
||||
{
|
||||
// Both SSL and non-SSL streams will act as non-SSL streams
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -326,7 +347,7 @@ BOOST_MYSQL_NETWORK_TEST(ssl_disable, handshake_fixture)
|
||||
BOOST_TEST(!conn->uses_ssl());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_NOSSL(ssl_enable_nonssl_streams, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_enable_nonssl_streams, handshake_fixture, net_samples_nossl)
|
||||
{
|
||||
// Ignored by non-ssl streams
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -335,7 +356,7 @@ BOOST_MYSQL_NETWORK_TEST_NOSSL(ssl_enable_nonssl_streams, handshake_fixture)
|
||||
BOOST_TEST(!conn->uses_ssl());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(ssl_enable_ssl_streams, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_enable_ssl_streams, handshake_fixture, net_samples_ssl)
|
||||
{
|
||||
// In all our CI systems, our servers support SSL, so
|
||||
// ssl_mode::enable will do the same as ssl_mode::require.
|
||||
@@ -346,7 +367,7 @@ BOOST_MYSQL_NETWORK_TEST_SSL(ssl_enable_ssl_streams, handshake_fixture)
|
||||
BOOST_TEST(conn->uses_ssl());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_NOSSL(ssl_require_nonssl_streams, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_require_nonssl_streams, handshake_fixture, net_samples_nossl)
|
||||
{
|
||||
// Ignored by non-ssl streams
|
||||
setup_and_physical_connect(sample.net);
|
||||
@@ -355,7 +376,7 @@ BOOST_MYSQL_NETWORK_TEST_NOSSL(ssl_require_nonssl_streams, handshake_fixture)
|
||||
BOOST_TEST(!conn->uses_ssl());
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_SSL(ssl_require_ssl_streams, handshake_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ssl_require_ssl_streams, handshake_fixture, net_samples_ssl)
|
||||
{
|
||||
setup_and_physical_connect(sample.net);
|
||||
params.set_ssl(ssl_mode::require);
|
||||
|
||||
@@ -23,9 +23,13 @@ using boost::mysql::tcp_statement;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples = create_network_samples(
|
||||
{"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"}
|
||||
);
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_prepare_statement)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(ok_no_params, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ok_no_params, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
conn->prepare_statement("SELECT * FROM empty_table", *stmt).validate_no_error();
|
||||
@@ -34,7 +38,7 @@ BOOST_MYSQL_NETWORK_TEST(ok_no_params, network_fixture)
|
||||
BOOST_TEST(stmt->base().num_params() == 0u);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
conn->prepare_statement("SELECT * FROM empty_table WHERE id IN (?, ?)", *stmt)
|
||||
@@ -44,7 +48,7 @@ BOOST_MYSQL_NETWORK_TEST(ok_with_params, network_fixture)
|
||||
BOOST_TEST(stmt->base().num_params() == 2u);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(invalid_statement, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(invalid_statement, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
conn->prepare_statement("SELECT * FROM bad_table WHERE id IN (?, ?)", *stmt)
|
||||
|
||||
@@ -14,9 +14,15 @@
|
||||
using namespace boost::mysql::test;
|
||||
using boost::mysql::errc;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples = create_network_samples(
|
||||
{"tcp_sync_errc", "tcp_sync_exc", "tcp_async_callback", "tcp_async_callback_noerrinfo"}
|
||||
);
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_query)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(insert_ok, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(insert_ok, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
@@ -41,7 +47,7 @@ BOOST_MYSQL_NETWORK_TEST(insert_ok, network_fixture)
|
||||
BOOST_TEST(this->get_table_size("inserts_table") == 1u);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(insert_error, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(insert_error, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
@@ -52,7 +58,7 @@ BOOST_MYSQL_NETWORK_TEST(insert_error, network_fixture)
|
||||
netresult.validate_error(errc::no_such_table, {"table", "doesn't exist", "bad_table"});
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(update_ok, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(update_ok, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
@@ -75,7 +81,7 @@ BOOST_MYSQL_NETWORK_TEST(update_ok, network_fixture)
|
||||
BOOST_TEST(updated_value == 52); // initial value was 42
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(select_ok, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(select_ok, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
@@ -86,7 +92,7 @@ BOOST_MYSQL_NETWORK_TEST(select_ok, network_fixture)
|
||||
this->validate_2fields_meta(result->base(), "empty_table");
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(select_error, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(select_error, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
auto netresult = conn->query("SELECT field_varchar, field_bad FROM one_row_table", *result);
|
||||
@@ -94,3 +100,5 @@ BOOST_MYSQL_NETWORK_TEST(select_error, network_fixture)
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // test_query
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -10,9 +10,13 @@
|
||||
using namespace boost::mysql::test;
|
||||
using boost::mysql::error_code;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"});
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_quit_connection)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(active_connection, network_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(active_connection, network_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
@@ -24,3 +28,5 @@ BOOST_MYSQL_NETWORK_TEST(active_connection, network_fixture)
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // test_quit_connection
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -19,6 +19,11 @@ using namespace boost::mysql::test;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples_nossl = create_network_samples({"tcp_sync_errc", "tcp_async_callback"});
|
||||
auto net_samples_all = create_network_samples(
|
||||
{"tcp_sync_errc", "tcp_async_callback", "tcp_ssl_sync_errc", "tcp_ssl_async_callback"}
|
||||
);
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_reconnect)
|
||||
|
||||
struct reconnect_fixture : network_fixture
|
||||
@@ -31,7 +36,7 @@ struct reconnect_fixture : network_fixture
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_NOSSL(reconnect_after_close, reconnect_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(reconnect_after_close, reconnect_fixture, net_samples_nossl)
|
||||
{
|
||||
setup(sample.net);
|
||||
|
||||
@@ -47,7 +52,7 @@ BOOST_MYSQL_NETWORK_TEST_NOSSL(reconnect_after_close, reconnect_fixture)
|
||||
do_query_ok();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_NOSSL(reconnect_after_handshake_error, reconnect_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(reconnect_after_handshake_error, reconnect_fixture, net_samples_nossl)
|
||||
{
|
||||
setup(sample.net);
|
||||
|
||||
@@ -62,7 +67,7 @@ BOOST_MYSQL_NETWORK_TEST_NOSSL(reconnect_after_handshake_error, reconnect_fixtur
|
||||
do_query_ok();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(reconnect_after_physical_connect_error, reconnect_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(reconnect_after_physical_connect_error, reconnect_fixture, net_samples_all)
|
||||
{
|
||||
setup(sample.net);
|
||||
|
||||
|
||||
@@ -92,24 +92,11 @@ std::ostream& operator<<(std::ostream& os, const resultset_sample& input)
|
||||
return os << static_cast<const network_sample&>(input) << '_' << input.gen->name();
|
||||
}
|
||||
|
||||
struct sample_gen
|
||||
{
|
||||
std::vector<resultset_sample> make_all() const
|
||||
{
|
||||
std::vector<resultset_sample> res;
|
||||
for (auto* net : all_variants())
|
||||
{
|
||||
res.emplace_back(net, &text_obj);
|
||||
res.emplace_back(net, &binary_obj);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const std::vector<resultset_sample>& operator()() const
|
||||
{
|
||||
static const auto res = make_all();
|
||||
return res;
|
||||
}
|
||||
resultset_sample net_samples[] = {
|
||||
resultset_sample(get_variant("tcp_sync_errc"), &text_obj),
|
||||
resultset_sample(get_variant("tcp_async_callback"), &text_obj),
|
||||
resultset_sample(get_variant("tcp_sync_exc"), &binary_obj),
|
||||
resultset_sample(get_variant("tcp_async_callback_noerrinfo"), &binary_obj),
|
||||
};
|
||||
|
||||
struct resultset_fixture : network_fixture
|
||||
@@ -131,7 +118,7 @@ struct resultset_fixture : network_fixture
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(read_one)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(no_results, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM empty_table");
|
||||
@@ -150,7 +137,7 @@ BOOST_MYSQL_NETWORK_TEST_EX(no_results, resultset_fixture, sample_gen())
|
||||
validate_eof(*result);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(one_row, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM one_row_table");
|
||||
@@ -170,7 +157,7 @@ BOOST_MYSQL_NETWORK_TEST_EX(one_row, resultset_fixture, sample_gen())
|
||||
validate_eof(*result);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(two_rows, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(two_rows, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM two_rows_table");
|
||||
@@ -200,7 +187,7 @@ BOOST_AUTO_TEST_SUITE_END() // read_one
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(read_some)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(no_results, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM empty_table");
|
||||
@@ -216,7 +203,7 @@ BOOST_MYSQL_NETWORK_TEST_EX(no_results, resultset_fixture, sample_gen())
|
||||
validate_eof(*result);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(one_row, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM one_row_table");
|
||||
@@ -237,7 +224,7 @@ BOOST_MYSQL_NETWORK_TEST_EX(one_row, resultset_fixture, sample_gen())
|
||||
validate_eof(*result);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(several_rows, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(several_rows, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM three_rows_table");
|
||||
@@ -268,7 +255,7 @@ BOOST_MYSQL_NETWORK_TEST_EX(several_rows, resultset_fixture, sample_gen())
|
||||
validate_eof(*result);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(several_rows_single_read, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(several_rows_single_read, resultset_fixture, net_samples)
|
||||
{
|
||||
// make sure the entire result can be read at once
|
||||
params.set_buffer_config(boost::mysql::buffer_params(4096));
|
||||
@@ -290,7 +277,7 @@ BOOST_AUTO_TEST_SUITE_END() // read_many
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(read_all)
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(no_results, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(no_results, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM empty_table");
|
||||
@@ -306,7 +293,7 @@ BOOST_MYSQL_NETWORK_TEST_EX(no_results, resultset_fixture, sample_gen())
|
||||
validate_eof(*result);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(one_row, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(one_row, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM one_row_table");
|
||||
@@ -322,7 +309,7 @@ BOOST_MYSQL_NETWORK_TEST_EX(one_row, resultset_fixture, sample_gen())
|
||||
validate_eof(*result);
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(several_rows, resultset_fixture, sample_gen())
|
||||
BOOST_MYSQL_NETWORK_TEST(several_rows, resultset_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample);
|
||||
generate("SELECT * FROM two_rows_table");
|
||||
|
||||
@@ -15,6 +15,8 @@ using boost::mysql::field_view;
|
||||
|
||||
namespace {
|
||||
|
||||
auto net_samples = create_network_samples({"tcp_sync_errc", "tcp_async_callback"});
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(test_statement_lifecycle)
|
||||
|
||||
struct statement_lifecycle_fixture : network_fixture
|
||||
@@ -30,7 +32,7 @@ struct statement_lifecycle_fixture : network_fixture
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(select_with_parameters_multiple_executions, statement_lifecycle_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(select_with_parameters, statement_lifecycle_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
|
||||
@@ -65,7 +67,7 @@ BOOST_MYSQL_NETWORK_TEST(select_with_parameters_multiple_executions, statement_l
|
||||
stmt->close().validate_no_error();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(insert_with_parameters_multiple_executions, statement_lifecycle_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(insert_with_parameters, statement_lifecycle_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
@@ -93,7 +95,7 @@ BOOST_MYSQL_NETWORK_TEST(insert_with_parameters_multiple_executions, statement_l
|
||||
stmt->close().validate_no_error();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(update_with_parameters_multiple_executions, statement_lifecycle_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(update_with_parameters, statement_lifecycle_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
@@ -124,7 +126,7 @@ BOOST_MYSQL_NETWORK_TEST(update_with_parameters_multiple_executions, statement_l
|
||||
stmt->close().validate_no_error();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(multiple_statements, statement_lifecycle_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(multiple_statements, statement_lifecycle_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
@@ -174,7 +176,7 @@ BOOST_MYSQL_NETWORK_TEST(multiple_statements, statement_lifecycle_fixture)
|
||||
stmt_select->close().validate_no_error();
|
||||
}
|
||||
|
||||
BOOST_MYSQL_NETWORK_TEST(insert_with_null_values, statement_lifecycle_fixture)
|
||||
BOOST_MYSQL_NETWORK_TEST(insert_with_null_values, statement_lifecycle_fixture, net_samples)
|
||||
{
|
||||
setup_and_connect(sample.net);
|
||||
start_transaction();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/ssl/context.hpp>
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/utility/string_view.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -27,15 +28,14 @@ public:
|
||||
virtual bool supports_ssl() const = 0;
|
||||
virtual const char* stream_name() const = 0;
|
||||
virtual const char* variant_name() const = 0;
|
||||
std::string name() const { return std::string(stream_name()) + '_' + variant_name(); }
|
||||
virtual er_connection_ptr create_connection(boost::asio::io_context::executor_type, boost::asio::ssl::context&) = 0;
|
||||
virtual er_resultset_ptr create_resultset() = 0;
|
||||
virtual er_statement_ptr create_statement() = 0;
|
||||
};
|
||||
|
||||
boost::span<er_network_variant*> all_variants();
|
||||
boost::span<er_network_variant*> ssl_variants();
|
||||
boost::span<er_network_variant*> non_ssl_variants();
|
||||
er_network_variant* tcp_sync_errc_variant();
|
||||
er_network_variant* get_variant(boost::string_view name);
|
||||
|
||||
} // namespace test
|
||||
} // namespace mysql
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <boost/asio/ssl/context.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <initializer_list>
|
||||
#include <thread>
|
||||
|
||||
#include "er_connection.hpp"
|
||||
@@ -156,62 +157,13 @@ inline std::ostream& operator<<(std::ostream& os, const network_sample& value)
|
||||
return os << value.net->stream_name() << "_" << value.net->variant_name();
|
||||
}
|
||||
|
||||
struct all_variants_gen
|
||||
inline std::vector<network_sample> create_network_samples(std::initializer_list<const char*> names)
|
||||
{
|
||||
std::vector<network_sample> make_all() const
|
||||
{
|
||||
std::vector<network_sample> res;
|
||||
for (auto* net : all_variants())
|
||||
{
|
||||
res.emplace_back(net);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const std::vector<network_sample>& operator()() const
|
||||
{
|
||||
static auto res = make_all();
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
struct ssl_only_gen
|
||||
{
|
||||
std::vector<network_sample> make_all() const
|
||||
{
|
||||
std::vector<network_sample> res;
|
||||
for (auto* net : ssl_variants())
|
||||
{
|
||||
res.emplace_back(net);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const std::vector<network_sample>& operator()() const
|
||||
{
|
||||
static auto res = make_all();
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
struct non_ssl_only_gen
|
||||
{
|
||||
std::vector<network_sample> make_all() const
|
||||
{
|
||||
std::vector<network_sample> res;
|
||||
for (auto* net : non_ssl_variants())
|
||||
{
|
||||
res.emplace_back(net);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
const std::vector<network_sample>& operator()() const
|
||||
{
|
||||
static auto res = make_all();
|
||||
return res;
|
||||
}
|
||||
};
|
||||
std::vector<network_sample> res;
|
||||
for (const char* name : names)
|
||||
res.emplace_back(get_variant(name));
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace mysql
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <iterator>
|
||||
|
||||
/**
|
||||
* Defines the required infrastructure for network tests.
|
||||
* These are data-driven (parametrized) test cases. We don't
|
||||
@@ -34,9 +36,9 @@ namespace mysql {
|
||||
namespace test {
|
||||
|
||||
// The type of a sample generated by DataGenerator
|
||||
template <class DataGen>
|
||||
using data_gen_sample_type = typename std::decay<
|
||||
decltype(std::declval<typename std::decay<DataGen>::type>()()[0])>::type;
|
||||
template <class SampleCollection>
|
||||
using sample_type = typename std::decay<decltype(*std::begin(std::declval<const SampleCollection&>()
|
||||
))>::type;
|
||||
|
||||
inline boost::unit_test::test_suite* create_test_suite(
|
||||
boost::unit_test::const_string tc_name,
|
||||
@@ -62,19 +64,19 @@ inline boost::unit_test::test_suite* create_test_suite(
|
||||
template <class Testcase>
|
||||
struct network_test_registrar
|
||||
{
|
||||
template <class DataGen>
|
||||
template <class SampleCollection>
|
||||
network_test_registrar(
|
||||
boost::unit_test::const_string tc_name,
|
||||
boost::unit_test::const_string tc_file,
|
||||
std::size_t tc_line,
|
||||
const DataGen& datagen
|
||||
const SampleCollection& samples
|
||||
)
|
||||
{
|
||||
// Create suite
|
||||
auto* suite = create_test_suite(tc_name, tc_file, tc_line);
|
||||
|
||||
// Create a test for each sample
|
||||
for (const auto& sample : datagen())
|
||||
for (const auto& sample : samples)
|
||||
{
|
||||
std::string test_name = detail::stringize(sample);
|
||||
auto* test = boost::unit_test::make_test_case(
|
||||
@@ -96,22 +98,13 @@ struct network_test_registrar
|
||||
} // namespace mysql
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_MYSQL_NETWORK_TEST_EX(name, fixture, sample_generator) \
|
||||
struct name : public fixture \
|
||||
{ \
|
||||
void test_method(const data_gen_sample_type<decltype(sample_generator)>&); \
|
||||
}; \
|
||||
static ::boost::mysql::test::network_test_registrar<name> name##_registrar \
|
||||
BOOST_ATTRIBUTE_UNUSED(#name, __FILE__, __LINE__, sample_generator); \
|
||||
void name::test_method(const data_gen_sample_type<decltype(sample_generator)>& sample)
|
||||
|
||||
#define BOOST_MYSQL_NETWORK_TEST(name, fixture) \
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(name, fixture, all_variants_gen())
|
||||
|
||||
#define BOOST_MYSQL_NETWORK_TEST_SSL(name, fixture) \
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(name, fixture, ssl_only_gen())
|
||||
|
||||
#define BOOST_MYSQL_NETWORK_TEST_NOSSL(name, fixture) \
|
||||
BOOST_MYSQL_NETWORK_TEST_EX(name, fixture, non_ssl_only_gen())
|
||||
#define BOOST_MYSQL_NETWORK_TEST(name, fixture, samples) \
|
||||
struct name : public fixture \
|
||||
{ \
|
||||
void test_method(const sample_type<decltype(samples)>&); \
|
||||
}; \
|
||||
static ::boost::mysql::test::network_test_registrar<name> name##_registrar \
|
||||
BOOST_ATTRIBUTE_UNUSED(#name, __FILE__, __LINE__, samples); \
|
||||
void name::test_method(const sample_type<decltype(samples)>& sample)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "er_impl_common.hpp"
|
||||
#include "er_network_variant.hpp"
|
||||
@@ -30,23 +32,11 @@ static std::vector<er_network_variant*> make_all_variants()
|
||||
return res;
|
||||
}
|
||||
|
||||
static std::vector<er_network_variant*> make_ssl_variants()
|
||||
static std::unordered_map<std::string, er_network_variant*> make_variants_map()
|
||||
{
|
||||
auto all = make_all_variants();
|
||||
std::vector<er_network_variant*> res;
|
||||
std::copy_if(all.begin(), all.end(), std::back_inserter(res), [](er_network_variant* v) {
|
||||
return v->supports_ssl();
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
static std::vector<er_network_variant*> make_non_ssl_variants()
|
||||
{
|
||||
auto all = make_all_variants();
|
||||
std::vector<er_network_variant*> res;
|
||||
std::copy_if(all.begin(), all.end(), std::back_inserter(res), [](er_network_variant* v) {
|
||||
return !v->supports_ssl();
|
||||
});
|
||||
std::unordered_map<std::string, er_network_variant*> res;
|
||||
for (auto* var : all_variants())
|
||||
res[var->name()] = var;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -56,14 +46,12 @@ boost::span<er_network_variant*> boost::mysql::test::all_variants()
|
||||
return res;
|
||||
}
|
||||
|
||||
boost::span<er_network_variant*> boost::mysql::test::ssl_variants()
|
||||
er_network_variant* boost::mysql::test::get_variant(boost::string_view name)
|
||||
{
|
||||
static auto res = make_ssl_variants();
|
||||
return res;
|
||||
}
|
||||
|
||||
boost::span<er_network_variant*> boost::mysql::test::non_ssl_variants()
|
||||
{
|
||||
static auto res = make_non_ssl_variants();
|
||||
return res;
|
||||
static auto by_name = make_variants_map();
|
||||
std::string name_str(name);
|
||||
auto it = by_name.find(name_str);
|
||||
if (it == by_name.end())
|
||||
throw std::out_of_range("Unknown network variant: " + name_str);
|
||||
return it->second;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user