Migrate tests to storage v2 part 1
Reviewers: teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2554
This commit is contained in:
@@ -2,9 +2,8 @@
|
||||
#include "bolt_testdata.hpp"
|
||||
|
||||
#include "communication/bolt/v1/encoder/encoder.hpp"
|
||||
#include "database/single_node/graph_db.hpp"
|
||||
#include "database/single_node/graph_db_accessor.hpp"
|
||||
#include "glue/communication.hpp"
|
||||
#include "storage/v2/storage.hpp"
|
||||
|
||||
using communication::bolt::Value;
|
||||
|
||||
@@ -164,50 +163,50 @@ TEST(BoltEncoder, VertexAndEdge) {
|
||||
output.clear();
|
||||
|
||||
// create vertex
|
||||
database::GraphDb db;
|
||||
auto db_accessor = db.Access();
|
||||
auto va1 = db_accessor.InsertVertex();
|
||||
auto va2 = db_accessor.InsertVertex();
|
||||
auto l1 = db_accessor.Label("label1");
|
||||
auto l2 = db_accessor.Label("label2");
|
||||
va1.add_label(l1);
|
||||
va1.add_label(l2);
|
||||
auto p1 = db_accessor.Property("prop1");
|
||||
auto p2 = db_accessor.Property("prop2");
|
||||
storage::Storage db;
|
||||
auto dba = db.Access();
|
||||
auto va1 = dba.CreateVertex();
|
||||
auto va2 = dba.CreateVertex();
|
||||
auto l1 = dba.NameToLabel("label1");
|
||||
auto l2 = dba.NameToLabel("label2");
|
||||
ASSERT_TRUE(va1.AddLabel(l1).HasValue());
|
||||
ASSERT_TRUE(va1.AddLabel(l2).HasValue());
|
||||
auto p1 = dba.NameToProperty("prop1");
|
||||
auto p2 = dba.NameToProperty("prop2");
|
||||
PropertyValue pv1(12), pv2(200);
|
||||
va1.PropsSet(p1, pv1);
|
||||
va1.PropsSet(p2, pv2);
|
||||
ASSERT_TRUE(va1.SetProperty(p1, pv1).HasValue());
|
||||
ASSERT_TRUE(va1.SetProperty(p2, pv2).HasValue());
|
||||
|
||||
// create edge
|
||||
auto et = db_accessor.EdgeType("edgetype");
|
||||
auto ea = db_accessor.InsertEdge(va1, va2, et);
|
||||
auto p3 = db_accessor.Property("prop3");
|
||||
auto p4 = db_accessor.Property("prop4");
|
||||
auto et = dba.NameToEdgeType("edgetype");
|
||||
auto ea = dba.CreateEdge(&va1, &va2, et);
|
||||
auto p3 = dba.NameToProperty("prop3");
|
||||
auto p4 = dba.NameToProperty("prop4");
|
||||
PropertyValue pv3(42), pv4(1234);
|
||||
ea.PropsSet(p3, pv3);
|
||||
ea.PropsSet(p4, pv4);
|
||||
ASSERT_TRUE(ea->SetProperty(p3, pv3).HasValue());
|
||||
ASSERT_TRUE(ea->SetProperty(p4, pv4).HasValue());
|
||||
|
||||
// check everything
|
||||
std::vector<Value> vals;
|
||||
vals.push_back(glue::ToBoltValue(
|
||||
query::TypedValue(query::VertexAccessor(va1)), storage::View::NEW));
|
||||
vals.push_back(glue::ToBoltValue(
|
||||
query::TypedValue(query::VertexAccessor(va2)), storage::View::NEW));
|
||||
vals.push_back(glue::ToBoltValue(query::TypedValue(query::EdgeAccessor(ea)),
|
||||
storage::View::NEW));
|
||||
vals.push_back(*glue::ToBoltValue(
|
||||
query::TypedValue(query::VertexAccessor(va1)), db, storage::View::NEW));
|
||||
vals.push_back(*glue::ToBoltValue(
|
||||
query::TypedValue(query::VertexAccessor(va2)), db, storage::View::NEW));
|
||||
vals.push_back(*glue::ToBoltValue(query::TypedValue(query::EdgeAccessor(*ea)),
|
||||
db, storage::View::NEW));
|
||||
bolt_encoder.MessageRecord(vals);
|
||||
|
||||
// The vertexedge_encoded testdata has hardcoded zeros for IDs,
|
||||
// and Memgraph now encodes IDs so we need to check the output
|
||||
// part by part.
|
||||
CheckOutput(output, vertexedge_encoded, 5, false);
|
||||
CheckInt(output, va1.gid().AsInt());
|
||||
CheckInt(output, va1.Gid().AsInt());
|
||||
CheckOutput(output, vertexedge_encoded + 6, 34, false);
|
||||
CheckInt(output, va2.gid().AsInt());
|
||||
CheckInt(output, va2.Gid().AsInt());
|
||||
CheckOutput(output, vertexedge_encoded + 41, 4, false);
|
||||
CheckInt(output, ea.gid().AsInt());
|
||||
CheckInt(output, va1.gid().AsInt());
|
||||
CheckInt(output, va2.gid().AsInt());
|
||||
CheckInt(output, ea->Gid().AsInt());
|
||||
CheckInt(output, va1.Gid().AsInt());
|
||||
CheckInt(output, va2.Gid().AsInt());
|
||||
CheckOutput(output, vertexedge_encoded + 48, 26);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user