Skip to content

Commit

Permalink
Merge pull request #65 from tgockel/issue/58/watch-on-close
Browse files Browse the repository at this point in the history
client: Change connection_zk to deliver watch callbacks on close.
  • Loading branch information
tgockel authored Jan 19, 2018
2 parents 9e25083 + 9f24d9a commit 88f9f94
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 147 deletions.
40 changes: 40 additions & 0 deletions src/zk/client_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <zk/server/server_tests.hpp>

#include "client.hpp"

namespace zk
{

class client_tests :
public server::single_server_fixture
{ };

GTEST_TEST_F(client_tests, watch_close)
{
client c = get_connected_client();
auto watch = c.watch("/").get();

c.close();

// watch should be triggered with session closed
auto ev = watch.next().get();
CHECK_EQ(ev.type(), event_type::session);
CHECK_EQ(ev.state(), state::closed);
}

class stopping_client_tests :
public server::server_fixture
{ };

GTEST_TEST_F(stopping_client_tests, watch_server_stop)
{
client c = get_connected_client();
auto watch = c.watch("/").get();

this->stop_server(true);

auto ev = watch.next().get();
CHECK_EQ(ev.type(), event_type::session);
}

}
Loading

0 comments on commit 88f9f94

Please sign in to comment.