71d8062af1
Summary: A single line (graph_db.cpp:109 in the new code) was missing. This should have been done in D355 (made by DGleich, approved by Flor AND Buda AND Mislav :D). Converted a lambda to a method for convenience. Reviewers: buda, dgleich, mislav.bradac Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D665
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include <memory>
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "database/graph_db.hpp"
|
|
#include "database/graph_db_accessor.hpp"
|
|
#include "database/graph_db_datatypes.hpp"
|
|
#include "database/indexes/label_property_index.hpp"
|
|
|
|
class GraphDbTest : public testing::Test {
|
|
protected:
|
|
GraphDb graph_db{"default", fs::path()};
|
|
std::unique_ptr<GraphDbAccessor> dba =
|
|
std::make_unique<GraphDbAccessor>(graph_db);
|
|
|
|
void Commit() {
|
|
dba->Commit();
|
|
auto dba2 = std::make_unique<GraphDbAccessor>(graph_db);
|
|
dba.swap(dba2);
|
|
}
|
|
};
|
|
|
|
TEST_F(GraphDbTest, GarbageCollectIndices) {
|
|
auto label = dba->Label("label");
|
|
auto property = dba->Property("property");
|
|
dba->BuildIndex(label, property);
|
|
Commit();
|
|
|
|
auto vertex = dba->InsertVertex();
|
|
vertex.add_label(label);
|
|
vertex.PropsSet(property, 42);
|
|
Commit();
|
|
|
|
EXPECT_EQ(dba->VerticesCount(label, property), 1);
|
|
auto vertex_transferred = dba->Transfer(vertex);
|
|
dba->RemoveVertex(vertex_transferred.value());
|
|
EXPECT_EQ(dba->VerticesCount(label, property), 1);
|
|
Commit();
|
|
EXPECT_EQ(dba->VerticesCount(label, property), 1);
|
|
graph_db.CollectGarbage();
|
|
EXPECT_EQ(dba->VerticesCount(label, property), 0);
|
|
|
|
}
|