Horizon Official Technical Documentation
AuthServerTest.cpp File Reference
#include "Server/Auth/Auth.hpp"
#include <boost/test/included/unit_test.hpp>
+ Include dependency graph for AuthServerTest.cpp:

Macros

#define BOOST_TEST_MODULE   AuthServerTest
 

Functions

 BOOST_AUTO_TEST_CASE (AuthServerTest)
 
 BOOST_AUTO_TEST_CASE (DatabaseProcessTest)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   AuthServerTest

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( AuthServerTest  )
39{
40 BOOST_CHECK_NO_THROW([]() {
41 try {
42 sAuth->general_conf().set_test_run(TEST_RUN_MINIMAL);
43
44 sAuth->general_conf().set_config_file_path("config/auth-server.lua.dist");
45 sAuth->read_config();
47 // Running initialize() in a separate thread will cause a memory leak due to the singleton pattern.
48 // Always invoked on the main thread.
49 sAuth->initialize();
50
51 } catch(std::length_error &e) {
52 std::cerr << "Exception caught: " << e.what() << std::endl;
53 } catch(std::bad_alloc &e) {
54 std::cerr << "Exception caught: " << e.what() << std::endl;
55 } catch(std::exception &e) {
56 std::cerr << "Exception caught: " << e.what() << std::endl;
57 } catch(...) {
58 std::cerr << "Unknown exception caught." << std::endl;
59 }
60 });
61}
#define sAuth
Definition: Auth.hpp:131
@ TEST_RUN_MINIMAL
Definition: ServerConfiguration.hpp:40
void set_shutdown_signal(int signal)
Definition: Server.hpp:73
@ SHUTDOWN_INITIATED
Definition: Server.hpp:65

References sAuth, set_shutdown_signal(), SHUTDOWN_INITIATED, and TEST_RUN_MINIMAL.

+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( DatabaseProcessTest  )
64{
65 BOOST_CHECK_NO_THROW([]() {
66 // Feel free to change any of these values to what you see suit
67 std::string host = "127.0.0.1";
68 int port = 3306;
69 std::string user = "horizon";
70 std::string pass = "horizon";
71 std::string database = "horizon";
72 int segment_number = -1;
73
74 // Create the component
75 boost::asio::io_context ctx;
76 DatabaseProcess proc;
77
78 // Use it
79 try {
80 proc.initialize(ctx, segment_number, host, port, user, pass, database);
81 } catch(const std::exception &e) {
82 std::cerr << "Exception caught: " << e.what() << std::endl;
83 }
84 });
85}
Definition: Server.hpp:371
void initialize(int segment_number=1) override
Definition: Server.hpp:382

References DatabaseProcess::initialize().

+ Here is the call graph for this function: