Skip to content

Commit

Permalink
client: Change connection_zk to deliver watch callbacks on close.
Browse files Browse the repository at this point in the history
Issue #58
  • Loading branch information
tgockel committed Jan 19, 2018
1 parent 9e25083 commit 9f24d9a
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 9f24d9a

Please sign in to comment.