summaryrefslogtreecommitdiffhomepage
path: root/tests/test-whiteboard.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-28 17:06:57 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-28 17:06:57 +0100
commit4247b81e7756ce1ff01e097e634a9dcbc0912787 (patch)
treeaf14dd7aedf6b06826b5c15e3994431ed86f84a7 /tests/test-whiteboard.cpp
parenta61c702d91d7444ce0bb094ddccc70f72416500b (diff)
Added tests
Diffstat (limited to 'tests/test-whiteboard.cpp')
-rw-r--r--tests/test-whiteboard.cpp68
1 files changed, 7 insertions, 61 deletions
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 <cstring>
#include <filesystem>
#include <memory>
+#include <regex>
#include <string>
#include <system_error>
@@ -38,62 +39,6 @@ namespace {
const fs::path testDbFilename{"./whiteboard.db3"};
}
-class Webserver
-{
-public:
- Webserver()
- {
- File::setFile(webserverConfigFilename, R"CONFIG(
-<webserver>
- <user>www-data</user>
- <group>www-data</group>
- <threads>10</threads>
- <statisticspath>stats.db</statisticspath>
- <plugin-directory>../plugins</plugin-directory>
- <sites>
- <site>
- <host>[::1]</host>
- <path requested="/">
- <plugin>websocket</plugin>
- <target>::1:9876</target>
- </path>
- </site>
- </sites>
- <sockets>
- <socket>
- <address>::1</address>
- <port>8080</port>
- <protocol>http</protocol>
- <site>localhost</site>
- </socket>
- </sockets>
-</webserver>
-)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<Config>(testConfigFilename);
- //m_webserver = std::make_shared<Webserver>(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<Config> m_config;
- //std::shared_ptr<Webserver> 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;