From ca74c8858c7442f5a424ccebcabdfcab3ab76ce8 Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Tue, 6 May 2025 11:17:51 +0000 Subject: [PATCH 1/2] fix-testing --- src/config/config.hpp | 4 ++++ src/helpers.hpp | 1 + src/openrouter.cpp | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/config/config.hpp b/src/config/config.hpp index 171f7a4..1f485f3 100644 --- a/src/config/config.hpp +++ b/src/config/config.hpp @@ -2,5 +2,9 @@ #include namespace config { +#ifdef TEST + static ConfigManager config; +#else static ConfigManager config(std::string("../config.json")); +#endif } diff --git a/src/helpers.hpp b/src/helpers.hpp index d96a7a4..027bf26 100644 --- a/src/helpers.hpp +++ b/src/helpers.hpp @@ -2,6 +2,7 @@ #include #include #include +#include inline void check_body_empty(const httplib::Request& request, httplib::Response& response, std::string required_string) { if (request.body.empty()) { diff --git a/src/openrouter.cpp b/src/openrouter.cpp index 3af5888..fd49c09 100644 --- a/src/openrouter.cpp +++ b/src/openrouter.cpp @@ -3,10 +3,10 @@ int main() { - OpenRouter::OpenRouter router; #ifdef TEST return 0; #else + OpenRouter::OpenRouter router; return router.serve( config::config.getConfig()["server"]["ip"], config::config.getConfig()["server"]["port"] -- 2.54.0 From a9b28f0edd1d2beaa3e9c90c130e61db9493a414 Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Tue, 6 May 2025 11:24:41 +0000 Subject: [PATCH 2/2] updated actions --- .gitea/workflows/actions.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/actions.yaml b/.gitea/workflows/actions.yaml index cd96d10..23dd0be 100644 --- a/.gitea/workflows/actions.yaml +++ b/.gitea/workflows/actions.yaml @@ -13,11 +13,12 @@ jobs: uses: actions/checkout@v3 - name: Building binary with make run: | + sed -i '1s/^/#define TEST\n/' src/config/config.hpp && \ echo "#define TEST" >> src/OpenRouter/OpenRouter.hpp && \ make -j$(nproc) - name: Testing to run binary builded with make run: ./build/openrouter - + Prepare-Build-Testing-With-CMake: runs-on: alpine-sdk steps: @@ -29,6 +30,7 @@ jobs: uses: actions/checkout@v3 - name: Building binary with CMake run: | + sed -i '1s/^/#define TEST\n/' src/config/config.hpp && \ echo "#define TEST" >> src/OpenRouter/OpenRouter.hpp && \ mkdir build && \ cd build && \ @@ -36,7 +38,7 @@ jobs: make -j$(nproc) - name: Testing to run binary builded with CMake run: ./build/openrouter - + Prepare-Build-Testing-With-Meson: runs-on: alpine-sdk steps: @@ -48,8 +50,9 @@ jobs: uses: actions/checkout@v3 - name: Building binary with meson run: | + sed -i '1s/^/#define TEST\n/' src/config/config.hpp && \ echo "#define TEST" >> src/OpenRouter/OpenRouter.hpp && \ meson setup build && \ ninja -C build - name: Testing to run binary builded with meson - run: ./build/openrouter \ No newline at end of file + run: ./build/openrouter -- 2.54.0