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 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"]