Fix bug in StopServer function
Summary: Add test for system start and shutdown Reviewers: mferencevic, zuza Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D642
This commit is contained in:
parent
82f1cb333d
commit
bfe9ec0ab5
@ -33,7 +33,6 @@ std::pair<EventStream*, std::shared_ptr<Channel>> Reactor::Open(const std::strin
|
||||
std::unique_lock<std::mutex> lock(*mutex_);
|
||||
// TODO: Improve the check that the channel name does not exist in the
|
||||
// system.
|
||||
assert(connectors_.count(connector_name) == 0);
|
||||
if (connectors_.count(connector_name) != 0) {
|
||||
throw std::runtime_error("Connector with name " + connector_name
|
||||
+ "already exists");
|
||||
|
@ -546,9 +546,8 @@ class Network {
|
||||
void StopServer() {
|
||||
if (server_ != nullptr) {
|
||||
server_->Shutdown();
|
||||
server_ = nullptr;
|
||||
thread_.join();
|
||||
}
|
||||
thread_.join();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -10,6 +10,21 @@
|
||||
|
||||
#include "communication.hpp"
|
||||
|
||||
TEST(SystemTest, ReturnWithoutThrowing) {
|
||||
struct Master : public Reactor {
|
||||
Master(System *system, std::string name) : Reactor(system, name) {}
|
||||
virtual void Run() {
|
||||
CloseConnector("main");
|
||||
}
|
||||
};
|
||||
|
||||
System system;
|
||||
ASSERT_NO_THROW(system.StartServices());
|
||||
ASSERT_NO_THROW(system.Spawn<Master>("master"));
|
||||
ASSERT_NO_THROW(system.AwaitShutdown());
|
||||
}
|
||||
|
||||
|
||||
TEST(ChannelCreationTest, ThrowOnReusingChannelName) {
|
||||
struct Master : public Reactor {
|
||||
Master(System *system, std::string name) : Reactor(system, name) {}
|
||||
|
Loading…
Reference in New Issue
Block a user