memgraph/tests/unit/distributed_reset.cpp
Teon Banek 9f460914ed Separate distributed implementation of GraphDbAccessor
Summary:
GraphDbAccessor is now constructed only through GraphDb. This allows the
concrete GraphDb to instantiate a concrete GraphDbAccessor. This allows
us to use virtual calls, so that the implementation may be kept
separate. The major downside of doing things this way is heap allocation
of GraphDbAccessor. In case it turns out to be a real performance
issues, another solution with pointer to static implementation may be
used.

InsertVertexIntoRemote is now a non-member function, which reduces
coupling. It made no sense for it to be member function because it used
only the public parts of GraphDbAccessor.

Reviewers: msantl, mtomic, mferencevic

Reviewed By: msantl

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1504
2018-07-26 09:16:39 +02:00

36 lines
1.1 KiB
C++

#include "gtest/gtest.h"
#include "distributed/plan_dispatcher.hpp"
#include "distributed_common.hpp"
#include "query/context.hpp"
#include "query/interpret/frame.hpp"
class DistributedReset : public DistributedGraphDbTest {
protected:
DistributedReset() : DistributedGraphDbTest("reset") {}
};
TEST_F(DistributedReset, ResetTest) {
query::SymbolTable symbol_table;
auto once = std::make_shared<query::plan::Once>();
auto pull_remote = std::make_shared<query::plan::PullRemote>(
once, 42, std::vector<query::Symbol>());
master().plan_dispatcher().DispatchPlan(42, once, symbol_table);
auto dba = master().Access();
query::Frame frame(0);
query::Context context(*dba);
auto pull_remote_cursor = pull_remote->MakeCursor(*dba);
for (int i = 0; i < 3; ++i) {
EXPECT_TRUE(pull_remote_cursor->Pull(frame, context));
}
EXPECT_FALSE(pull_remote_cursor->Pull(frame, context));
pull_remote_cursor->Reset();
for (int i = 0; i < 3; ++i) {
EXPECT_TRUE(pull_remote_cursor->Pull(frame, context));
}
EXPECT_FALSE(pull_remote_cursor->Pull(frame, context));
}