mirror of
https://github.com/emqx/neuron.git
synced 2026-10-28 22:59:34 +08:00
mqtt schema test
This commit is contained in:
@@ -85,6 +85,14 @@ target_include_directories(cid_test PRIVATE
|
||||
)
|
||||
target_link_libraries(cid_test neuron-base gtest_main gtest)
|
||||
|
||||
add_executable(mqtt_schema_test mqtt_schema_test.cc ${CMAKE_SOURCE_DIR}/plugins/mqtt/schema.c)
|
||||
target_include_directories(mqtt_schema_test PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/plugins
|
||||
)
|
||||
target_link_libraries(mqtt_schema_test neuron-base gtest_main gtest)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(json_test)
|
||||
gtest_discover_tests(http_test)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "neuron.h"
|
||||
|
||||
#include "mqtt/schema.h"
|
||||
|
||||
int64_t global_timestamp = 0;
|
||||
zlog_category_t *neuron = NULL;
|
||||
|
||||
TEST(validate_success, schema)
|
||||
{
|
||||
const char *schema =
|
||||
"{\"timestamp\":\"${timestamp}\",\"node\":\"${node}\",\"group\":\"${"
|
||||
"group}\",\"tags\":\"${tag_values}\",\"static\":\"${static_"
|
||||
"tags}\",\"errors\":\"${tag_errors}\"}";
|
||||
mqtt_schema_vt_t *vts;
|
||||
size_t n_vts;
|
||||
int ret = mqtt_schema_validate(schema, &vts, &n_vts);
|
||||
EXPECT_EQ(ret, 0);
|
||||
|
||||
EXPECT_EQ(n_vts, 6);
|
||||
free(vts);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
zlog_init("./config/dev.conf");
|
||||
neuron = zlog_get_category("neuron");
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Reference in New Issue
Block a user