From c3d564b618667da0aa20ba262531c7f4a68cfea5 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Fri, 26 Jul 2024 11:31:03 +0300 Subject: [PATCH] add base transaction answer if success --- src/trs/libs/transaction.hpp | 5 +++- tests/main.cpp | 48 ++++++++++++++---------------------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/trs/libs/transaction.hpp b/src/trs/libs/transaction.hpp index 7194cf5..449c33b 100644 --- a/src/trs/libs/transaction.hpp +++ b/src/trs/libs/transaction.hpp @@ -28,7 +28,10 @@ namespace trs struct data { JSON m_payload; - JSON m_result; + JSON m_result { + { "status", "completed" }, + { "result", "" } + }; } m_data; public: diff --git a/tests/main.cpp b/tests/main.cpp index 8752c75..f528fb7 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -19,8 +19,8 @@ namespace worckspaces inline void provider(trs::transaction& tr) { hack::log()("provider", tr.m_data.m_payload); - tr.m_data.m_result["status"] = "ok"; - tr.m_data.m_result["result"] = "super ok"; + // tr.m_data.m_result["status"] = "ok"; + // tr.m_data.m_result["result"] = "super ok"; } } @@ -29,19 +29,19 @@ auto main(int argc, char* args[]) -> int // ATTENTION !!! // обязательно реализовать инициализацию БД - // const std::string con = "postgres://chatlanin:password_for_connection_to_test_db@localhost:5423/test.db?sslmode=disable"; - // - // try - // { - // PGXX().init("con_1", 300, con); - // PGXX().init("con_2", 300, con); - // } - // catch(hack::exception& ex) - // { - // ex.log(); - // throw; - // } - // + const std::string con = "postgres://chatlanin:password_for_connection_to_test_db@localhost:5423/test.db?sslmode=disable"; + + try + { + PGXX().init("con_1", 300, con); + PGXX().init("con_2", 300, con); + } + catch(hack::exception& ex) + { + ex.log(); + throw; + } + // trs::client cli {"localhost:5000"}; // cli.set_token("token"); // trs::client cli_2 { std::move(cli) }; @@ -50,20 +50,10 @@ auto main(int argc, char* args[]) -> int // auto r2 = cli_2.post("func_name", j); // // trs::client::upload("https://file-examples.com/storage/feaf4c715066a139295358c/2017/11/file_example_MP3_700KB.mp3", "/mnt/raid/projects/trs/test.mp3"); - // - // trs::server srv; - // srv.init("test service"); - // - // srv.registration("healthcheck", worckspaces::inspector, worckspaces::provider); - // srv.run(); + trs::server srv; + srv.init("test service"); - - - std::regex regex_pattern("https://.*\\.mp3"); - std::string url = "https://file-examples.com/storage/feaf4c715066a139295358c/2017/11/file_example_MP3_700KB.mp3"; - if (!std::regex_match(url, regex_pattern)) - { - hack::log()("error"); - } + srv.registration("healthcheck", worckspaces::inspector, worckspaces::provider); + srv.run(); }