Третий тест покрыт фикстурой

This commit is contained in:
Антон
2025-11-18 10:18:57 +03:00
parent 6c37738ef6
commit 1a52ba4c90
3 changed files with 24 additions and 25 deletions
@@ -33,7 +33,7 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Failed_Parse_Payload, AuthRegis
{
req.body() = "{ \"login\": ABS3 }"s;
BOOST_CHECK_EXCEPTION(executor->operator()(std::move(req)), session_exception, [](const session_exception& e) -> bool
BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception, [](const session_exception& e) -> bool
{
return e.code == beast::http::status::internal_server_error;
});
@@ -50,25 +50,14 @@ BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Invalid_Login_Data, AuthRegistr
req.body() = serialize(req_body);
BOOST_CHECK_EXCEPTION(executor->operator()(std::move(req)), session_exception, [](const session_exception& e) -> bool
BOOST_CHECK_EXCEPTION(executor(std::move(req)), session_exception, [](const session_exception& e) -> bool
{
return e.code == beast::http::status::unprocessable_entity;
});
}
BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Succesfull_User_Login)
BOOST_FIXTURE_TEST_CASE(AuthRegistrationExecutor_Succesfull_User_Login, AuthRegistrationExecutorTestFixture)
{
auto& argv = boost::unit_test::framework::master_test_suite().argv;
const std::string mysql_credentials = argv[1];
mysqlx::Session* mysql_session = new mysqlx::Session(mysql_credentials);
uad::SetMySqlSession(mysql_session);
auto user_dao = make_shared<MySQLUserDAO>(GetMySqlSession());
auto executor = RouteAuthRegistrationExecutor(GetMySqlSession(), user_dao);
Request req;
value req_body;
@@ -82,9 +71,6 @@ BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Succesfull_User_Login)
auto response = executor(std::move(req));
BOOST_CHECK_EQUAL(response.result(), http::status::created);
mysql_session->close();
delete mysql_session;
}
BOOST_AUTO_TEST_CASE(AuthRegistrationExecutor_Unsuccesfull_User_Login)