1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

allow system to choose port of webfuse server

This commit is contained in:
Falk Werner
2020-06-12 13:32:31 +02:00
parent e72e78180e
commit 8a03f16aa5
9 changed files with 59 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
#include "webfuse/tests/integration/server.hpp"
#include <thread>
#include <mutex>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
@@ -59,7 +60,7 @@ public:
config = wf_server_config_create();
wf_server_config_set_port(config, 8080);
wf_server_config_set_port(config, 0);
wf_server_config_set_mountpoint_factory(config,
&webfuse_test_server_create_mountpoint,
reinterpret_cast<void*>(base_dir));
@@ -92,6 +93,14 @@ public:
return is_shutdown_requested;
}
std::string GetUrl(void) const
{
int const port = wf_server_get_port(server);
std::ostringstream stream;
stream << "wss://localhost:" << port << "/";
return stream.str();
}
private:
void RequestShutdown()
{
@@ -136,5 +145,10 @@ char const * Server::GetBaseDir(void) const
return d->base_dir;
}
std::string Server::GetUrl(void) const
{
return d->GetUrl();
}
}

View File

@@ -1,6 +1,8 @@
#ifndef WF_TEST_INTEGRATION_SERVER_HPP
#define WF_TEST_INTEGRATION_SERVER_HPP
#include <string>
namespace webfuse_test
{
@@ -12,6 +14,7 @@ public:
void Start(void);
void Stop(void);
char const * GetBaseDir(void) const;
std::string GetUrl(void) const;
private:
class Private;
Private * d;

View File

@@ -38,7 +38,7 @@ namespace
void SetUp()
{
server = new Server();
provider = new Provider("wss://localhost:8080/");
provider = new Provider(server->GetUrl().c_str());
}
void TearDown()