From 4247b81e7756ce1ff01e097e634a9dcbc0912787 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 28 Jan 2023 17:06:57 +0100 Subject: Added tests --- tests/test-whiteboard.cpp | 68 +++++------------------------------------------ 1 file changed, 7 insertions(+), 61 deletions(-) (limited to 'tests/test-whiteboard.cpp') diff --git a/tests/test-whiteboard.cpp b/tests/test-whiteboard.cpp index a472d64..9e6b7fb 100644 --- a/tests/test-whiteboard.cpp +++ b/tests/test-whiteboard.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -38,62 +39,6 @@ namespace { const fs::path testDbFilename{"./whiteboard.db3"}; } -class Webserver -{ -public: - Webserver() - { - File::setFile(webserverConfigFilename, R"CONFIG( - - www-data - www-data - 10 - stats.db - ../plugins - - - [::1] - - websocket - ::1:9876 - - - - - -
::1
- 8080 - http - localhost -
-
-
-)CONFIG"); - start(); - } - - ~Webserver() - { - stop(); - fs::remove(webserverConfigFilename); - } - - void start() - { - m_child = bp::child("/usr/bin/webserver"s, "-c"s, webserverConfigFilename.generic_string()); - Process::wait_for_pid_listening_on(m_child.id(), 8080); - std::this_thread::sleep_for(std::chrono::milliseconds(20)); - } - - void stop() - { - m_child.terminate(); - } - -private: - bp::child m_child; -}; - class WhiteboardTest: public ::testing::Test { protected: @@ -118,8 +63,6 @@ protected: m_config = std::make_shared(testConfigFilename); - //m_webserver = std::make_shared(webserverConfigFilename); - m_pid = fork(); if (m_pid == -1) { throw std::runtime_error("Error on fork(): "s + strerror(errno)); @@ -151,7 +94,6 @@ protected: } std::shared_ptr m_config; - //std::shared_ptr m_webserver; pid_t m_pid{}; }; @@ -223,12 +165,16 @@ private: boost::asio::ip::tcp::endpoint ep_; }; -TEST_F(WhiteboardTest, connection) +// +// tests via websocket server in separate process (hides coverage) +// + +TEST_F(WhiteboardTest, websocket_server_connection) { WebsocketClient wc; } -TEST_F(WhiteboardTest, generate_id) +TEST_F(WhiteboardTest, websocket_server_generate_id) { WebsocketClient wc; -- cgit v1.2.3