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:
Sasa Stanko 2017-08-08 11:34:50 +02:00
parent 82f1cb333d
commit bfe9ec0ab5
3 changed files with 16 additions and 3 deletions

View File

@ -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");

View File

@ -546,9 +546,8 @@ class Network {
void StopServer() {
if (server_ != nullptr) {
server_->Shutdown();
server_ = nullptr;
thread_.join();
}
thread_.join();
}
private:

View File

@ -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) {}