/
farado
/
farado-binara
Обзор
Документация
Войти
/
farado
/
farado-binara
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
develop
tests/api/test_api_logout.cpp
77 строк
2 KB
Ostapenko Alexey
[common][datenaro][retejo][tests] Убраны лишние include, местами в пользу forward declaration.
13 янв 2024, 16:03
13 янв 2024, 16:03
f1e4442
Код
Авторство
О чём код?
#define BOOST_TEST_MODULE testLogout #include <memory> #include <thread> #include <boost/test/unit_test.hpp> #include <crow.h> #include "common/api/client.h" #include "common/api/result.hpp" #include "common/api/server.h" #include "common/api/server_helper.hpp" #include "common/more/uuid.h" class Server final { public: Server() : m_crowApplication(new crow::SimpleApp) { ADD_CROW_ROUTE_LOGOUT( (*m_crowApplication), [this]( const Uuids::Uuid& sessionUuid, const std::string& user ) -> bool { return bool( Uuids::nilUuid() != sessionUuid && "user" == user ); } ); m_runThread.reset(new std::thread( [this]() { m_crowApplication->port(8080).multithreaded().run(); } )); m_stopThread.reset(new std::thread( [this]() { stop(); } )); } ~Server() { m_stopThread->join(); m_runThread->join(); } private: std::unique_ptr<crow::SimpleApp> m_crowApplication; std::unique_ptr<std::thread> m_runThread; std::unique_ptr<std::thread> m_stopThread; void stop() { std::this_thread::sleep_for(std::chrono::seconds(2)); m_crowApplication->stop(); } }; Server server; Api::Client client("http://127.0.0.1:8080"); BOOST_AUTO_TEST_CASE(testCorrectLogout) { const auto result = client.logout(Uuids::newUuid(), "user"); BOOST_CHECK(result.m_isSuccess == true); } BOOST_AUTO_TEST_CASE(testNonCorrectLogout) { const auto result = client.logout(Uuids::nilUuid(), "admin"); BOOST_CHECK(result.m_isSuccess == false); }