Introduce mgp_trans api (#175)
* Added public interface for registering mgp_trans and extended modules accordingly * Added test for mgp_trans * Added mg.transformations() to the module registry Co-authored-by: János Benjamin Antal <antaljanosbenjamin@users.noreply.github.com>
This commit is contained in:
committed by
Antonio Andelic
parent
d6a6d280dd
commit
d80ff745eb
24
tests/unit/mgp_trans_c_api.cpp
Normal file
24
tests/unit/mgp_trans_c_api.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "query/procedure/mg_procedure_impl.hpp"
|
||||
#include "query/procedure/module.hpp"
|
||||
#include "test_utils.hpp"
|
||||
|
||||
TEST(MgpTransTest, TestMgpTransApi) {
|
||||
constexpr auto no_op_cb = [](const mgp_messages *msg, mgp_graph *graph, mgp_result *result, mgp_memory *memory) {};
|
||||
mgp_module module(utils::NewDeleteResource());
|
||||
// If this is false, then mgp_module_add_transformation()
|
||||
// correctly calls IsValidIdentifier(). We don't need to test
|
||||
// for different string cases as these are all handled by
|
||||
// IsValidIdentifier().
|
||||
// Maybe add a mock instead and expect IsValidIdentifier() to be called once?
|
||||
EXPECT_FALSE(mgp_module_add_transformation(&module, "dash-dash", no_op_cb));
|
||||
EXPECT_TRUE(module.transformations.size() == 0);
|
||||
|
||||
EXPECT_TRUE(mgp_module_add_transformation(&module, "transform", no_op_cb));
|
||||
EXPECT_NE(module.transformations.find("transform"), module.transformations.end());
|
||||
|
||||
// Try to register a transformation twice
|
||||
EXPECT_FALSE(mgp_module_add_transformation(&module, "transform", no_op_cb));
|
||||
EXPECT_TRUE(module.transformations.size() == 1);
|
||||
}
|
||||
Reference in New Issue
Block a user