1+ #define CATCH_CONFIG_RUNNER
2+ #include < catch2/catch_session.hpp>
13#include < catch2/catch_test_macros.hpp>
24#include < iostream>
35#include < ctime>
79#include " ../src/riot-cpp/client/client.h"
810#include " json.hpp"
911
10- #define CONFIG " ../../.api_keys/riot_config.json" , " ../test/log_file.txt" , logging::LEVEL::DEBUG, true
12+ static std::string api_key_path;
13+
14+ int main (int argc, char * argv[]) {
15+ Catch::Session session;
16+
17+ using namespace Catch ::Clara;
18+ auto cli = session.cli () | Opt (api_key_path, " api_key_path" )[" -p" ][" --path" ](" Path to riot_config.json" );
19+ session.cli (cli);
20+
21+ int returnCode = session.applyCommandLine (argc, argv);
22+ if (returnCode != 0 )
23+ return returnCode;
24+
25+ if (api_key_path.empty ()) {
26+ api_key_path = " ../../.api_keys/riot_config.json" ;
27+ }
28+
29+ return session.run ();
30+ }
31+
1132namespace riotcpp {
1233using namespace client ;
1334
35+ using namespace client ;
36+
1437static std::string ROUTING = " KR" ;
1538static std::string SUMMONER_ID;
1639static std::string PUUID;
@@ -21,7 +44,7 @@ using json = nlohmann::json;
2144
2245TEST_CASE ( " ACCOUNT_V1 QUERIES" ) {
2346 std::cout << " TESTING ACCOUNT_V1 QUERIES" << ' \n ' ;
24- RiotApiClient test_client (CONFIG );
47+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
2548
2649 std::vector<std::string> region = {" AMERICAS" , " ASIA" , " EUROPE" };
2750 std::string puuid; // puuid is key specific
@@ -59,7 +82,7 @@ TEST_CASE( "ACCOUNT_V1 QUERIES") {
5982
6083TEST_CASE ( " LEAGUE_V4 QUERIES" ) {
6184 std::cout << " TESTING LEAGUE_V4 QUERIES" << ' \n ' ;
62- RiotApiClient test_client (CONFIG );
85+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
6386
6487 std::string region = " na1" ;
6588 std::vector<std::string> queue = {" RANKED_SOLO_5x5" , " RANKED_FLEX_SR" };
@@ -131,7 +154,7 @@ TEST_CASE( "LEAGUE_V4 QUERIES") {
131154
132155TEST_CASE (" SUMMONER QUERIES " ) {
133156 std::cout << " TESTING SUMMONER QUERIES " << ' \n ' ;
134- RiotApiClient test_client (CONFIG );
157+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
135158
136159 std::string region = " kr" ;
137160 std::string summoner_name = " Hide on bush" ;
@@ -160,7 +183,7 @@ TEST_CASE(" SUMMONER QUERIES ") {
160183
161184TEST_CASE ( " MATCH QUERIES" ) {
162185 std::cout << " TESTING MATCH QUERIES" << ' \n ' ;
163- RiotApiClient test_client (CONFIG );
186+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
164187
165188 std::string region = " ASIA" ;
166189 std::string match_id = " KR_6279823690" ;
@@ -181,7 +204,7 @@ TEST_CASE( "MATCH QUERIES" ) {
181204
182205TEST_CASE (" CHAMPION-MASTERY-V4 QUERIES" ) {
183206 std::cout << " TESTING CHAMPION-MASTERY-V4 QUERIES" << ' \n ' ;
184- RiotApiClient test_client (CONFIG );
207+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
185208
186209 const int champion_id = 1 ;
187210 std::string endpoint = " CHAMPION-MASTERY-V4" ;
@@ -217,7 +240,7 @@ TEST_CASE("CHAMPION-MASTERY-V4 QUERIES") {
217240
218241TEST_CASE (" CHAMPION-V3" ) {
219242 std::cout << " TESTING CHAMPION-V3" << ' \n ' ;
220- RiotApiClient test_client (CONFIG );
243+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
221244
222245 json_ptr result;
223246 json doc;
@@ -230,7 +253,7 @@ TEST_CASE("CHAMPION-V3") {
230253
231254TEST_CASE (" LOL-CHALLENGES-V1" ) {
232255 std::cout << " TESTING LOL-CHALLENGES-V1" << ' \n ' ;
233- RiotApiClient test_client (CONFIG );
256+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
234257
235258 const int challenge_id = 1 ;
236259 std::string level = " HIGHEST" ;
@@ -263,7 +286,7 @@ TEST_CASE("LOL-CHALLENGES-V1") {
263286}
264287TEST_CASE (" LOL-STATUS" ) {
265288 std::cout << " TESTING LOL-STATUS" << ' \n ' ;
266- RiotApiClient test_client (CONFIG );
289+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
267290
268291 json_ptr result;
269292 json doc;
@@ -279,7 +302,7 @@ TEST_CASE("LOL-STATUS") {
279302}
280303TEST_CASE (" LOR-MATCH-V1" ) {
281304std::cout << " TESTING LOR-MATCH-V1" << ' \n ' ;
282- RiotApiClient test_client (CONFIG );
305+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
283306
284307 json_ptr result;
285308 std::string endpoint = " LOR-MATCH-V1" ;
@@ -300,7 +323,7 @@ std::cout << "TESTING LOR-MATCH-V1" << '\n';
300323}
301324TEST_CASE (" LOR-RANKED-V1" ) {
302325 std::cout << " TESTING LOR-RANKED-V1" << ' \n ' ;
303- RiotApiClient test_client (CONFIG );
326+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
304327
305328 json_ptr result;
306329 json doc;
@@ -312,7 +335,7 @@ TEST_CASE("LOR-RANKED-V1") {
312335}
313336TEST_CASE (" LOR-STATUS-V1" ) {
314337 std::cout << " TESTING LOR-STATUS-V1" << ' \n ' ;
315- RiotApiClient test_client (CONFIG );
338+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
316339
317340 json_ptr result;
318341 json doc;
@@ -327,7 +350,7 @@ TEST_CASE("LOR-STATUS-V1") {
327350}
328351TEST_CASE (" SPECTATOR-V4" ) {
329352 std::cout << " TESTING SPECTATOR-V4" << ' \n ' ;
330- RiotApiClient test_client (CONFIG );
353+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
331354
332355 json_ptr result;
333356 std::string endpoint = " SPECTATOR-V4" ;
@@ -365,7 +388,7 @@ TEST_CASE("SPECTATOR-V4") {
365388}
366389TEST_CASE (" TFT-LEAGUE-V1" ) {
367390 std::cout << " TESTING TFT-LEAGUE-V1" << ' \n ' ;
368- RiotApiClient test_client (CONFIG );
391+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
369392
370393 json_ptr result;
371394 std::string endpoint = " TFT-LEAGUE-V1" ;
@@ -423,7 +446,7 @@ TEST_CASE("TFT-LEAGUE-V1") {
423446}
424447TEST_CASE (" TFT-MATCH-V1" ) {
425448 std::cout << " TESTING TFT-MATCH-V1" << ' \n ' ;
426- RiotApiClient test_client (CONFIG );
449+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
427450
428451 json_ptr result;
429452 json doc;
@@ -459,7 +482,7 @@ TEST_CASE("TFT-MATCH-V1") {
459482}
460483TEST_CASE (" TFT-STATUS-V1" ) {
461484 std::cout << " TESTING TFT-STATUS-V1" << ' \n ' ;
462- RiotApiClient test_client (CONFIG );
485+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
463486
464487 json_ptr result;
465488 json doc;
@@ -472,7 +495,7 @@ TEST_CASE("TFT-STATUS-V1") {
472495}
473496TEST_CASE (" TFT-SUMMONER-V1" ) {
474497 std::cout << " TESTING TFT-SUMMONER-V1" << ' \n ' ;
475- RiotApiClient test_client (CONFIG );
498+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
476499
477500 json_ptr result;
478501 json doc;
@@ -503,7 +526,7 @@ TEST_CASE("TFT-SUMMONER-V1") {
503526}
504527TEST_CASE (" VAL-CONTENT-V1" ) {
505528 std::cout << " TESTING VAL-CONTENT-V1" << ' \n ' ;
506- RiotApiClient test_client (CONFIG );
529+ RiotApiClient test_client (api_key_path, " ../test/log_file.txt " , logging::LEVEL::DEBUG, true );
507530
508531 json_ptr result;
509532 json doc;
0 commit comments