Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ target_link_options(riot-cpp PRIVATE -fsanitize=address -static-libasan)

add_executable(client_tests test/client_tests.cpp test/simdjson.cpp)
target_link_libraries(client_tests riot-cpp)
target_link_libraries(client_tests Catch2::Catch2WithMain)
target_link_libraries(client_tests Catch2::Catch2)

target_compile_options(client_tests PRIVATE -fsanitize=address -static-libasan)
target_link_options(client_tests PRIVATE -fsanitize=address -static-libasan)
Expand Down
59 changes: 41 additions & 18 deletions test/client_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define CATCH_CONFIG_RUNNER
#include <catch2/catch_session.hpp>
#include <catch2/catch_test_macros.hpp>
#include <iostream>
#include <ctime>
Expand All @@ -7,10 +9,31 @@
#include "../src/riot-cpp/client/client.h"
#include "json.hpp"

#define CONFIG "../../.api_keys/riot_config.json", "../test/log_file.txt", logging::LEVEL::DEBUG, true
static std::string api_key_path;

int main(int argc, char* argv[]) {
Catch::Session session;

using namespace Catch::Clara;
auto cli = session.cli() | Opt(api_key_path, "api_key_path")["-p"]["--path"]("Path to riot_config.json");
session.cli(cli);

int returnCode = session.applyCommandLine(argc, argv);
if (returnCode != 0)
return returnCode;

if (api_key_path.empty()) {
api_key_path = "../../.api_keys/riot_config.json";
}

return session.run();
}

namespace riotcpp {
using namespace client;

using namespace client;

static std::string ROUTING = "KR";
static std::string SUMMONER_ID;
static std::string PUUID;
Expand All @@ -21,7 +44,7 @@ using json = nlohmann::json;

TEST_CASE( "ACCOUNT_V1 QUERIES") {
std::cout << "TESTING ACCOUNT_V1 QUERIES" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

std::vector<std::string> region = {"AMERICAS", "ASIA", "EUROPE"};
std::string puuid; // puuid is key specific
Expand Down Expand Up @@ -59,7 +82,7 @@ TEST_CASE( "ACCOUNT_V1 QUERIES") {

TEST_CASE( "LEAGUE_V4 QUERIES") {
std::cout << "TESTING LEAGUE_V4 QUERIES" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

std::string region = "na1";
std::vector<std::string> queue = {"RANKED_SOLO_5x5", "RANKED_FLEX_SR"};
Expand Down Expand Up @@ -131,7 +154,7 @@ TEST_CASE( "LEAGUE_V4 QUERIES") {

TEST_CASE(" SUMMONER QUERIES ") {
std::cout << "TESTING SUMMONER QUERIES " << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

std::string region = "kr";
std::string summoner_name = "Hide on bush";
Expand Down Expand Up @@ -160,7 +183,7 @@ TEST_CASE(" SUMMONER QUERIES ") {

TEST_CASE( "MATCH QUERIES" ) {
std::cout << "TESTING MATCH QUERIES" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

std::string region = "ASIA";
std::string match_id = "KR_6279823690";
Expand All @@ -181,7 +204,7 @@ TEST_CASE( "MATCH QUERIES" ) {

TEST_CASE("CHAMPION-MASTERY-V4 QUERIES") {
std::cout << "TESTING CHAMPION-MASTERY-V4 QUERIES" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

const int champion_id = 1;
std::string endpoint = "CHAMPION-MASTERY-V4";
Expand Down Expand Up @@ -217,7 +240,7 @@ TEST_CASE("CHAMPION-MASTERY-V4 QUERIES") {

TEST_CASE("CHAMPION-V3") {
std::cout << "TESTING CHAMPION-V3" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
json doc;
Expand All @@ -230,7 +253,7 @@ TEST_CASE("CHAMPION-V3") {

TEST_CASE("LOL-CHALLENGES-V1") {
std::cout << "TESTING LOL-CHALLENGES-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

const int challenge_id = 1;
std::string level = "HIGHEST";
Expand Down Expand Up @@ -263,7 +286,7 @@ TEST_CASE("LOL-CHALLENGES-V1") {
}
TEST_CASE("LOL-STATUS") {
std::cout << "TESTING LOL-STATUS" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
json doc;
Expand All @@ -279,7 +302,7 @@ TEST_CASE("LOL-STATUS") {
}
TEST_CASE("LOR-MATCH-V1") {
std::cout << "TESTING LOR-MATCH-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
std::string endpoint = "LOR-MATCH-V1";
Expand All @@ -300,7 +323,7 @@ std::cout << "TESTING LOR-MATCH-V1" << '\n';
}
TEST_CASE("LOR-RANKED-V1") {
std::cout << "TESTING LOR-RANKED-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
json doc;
Expand All @@ -312,7 +335,7 @@ TEST_CASE("LOR-RANKED-V1") {
}
TEST_CASE("LOR-STATUS-V1") {
std::cout << "TESTING LOR-STATUS-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
json doc;
Expand All @@ -327,7 +350,7 @@ TEST_CASE("LOR-STATUS-V1") {
}
TEST_CASE("SPECTATOR-V4") {
std::cout << "TESTING SPECTATOR-V4" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
std::string endpoint = "SPECTATOR-V4";
Expand Down Expand Up @@ -365,7 +388,7 @@ TEST_CASE("SPECTATOR-V4") {
}
TEST_CASE("TFT-LEAGUE-V1") {
std::cout << "TESTING TFT-LEAGUE-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
std::string endpoint = "TFT-LEAGUE-V1";
Expand Down Expand Up @@ -423,7 +446,7 @@ TEST_CASE("TFT-LEAGUE-V1") {
}
TEST_CASE("TFT-MATCH-V1") {
std::cout << "TESTING TFT-MATCH-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
json doc;
Expand Down Expand Up @@ -459,7 +482,7 @@ TEST_CASE("TFT-MATCH-V1") {
}
TEST_CASE("TFT-STATUS-V1") {
std::cout << "TESTING TFT-STATUS-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
json doc;
Expand All @@ -472,7 +495,7 @@ TEST_CASE("TFT-STATUS-V1") {
}
TEST_CASE("TFT-SUMMONER-V1") {
std::cout << "TESTING TFT-SUMMONER-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
json doc;
Expand Down Expand Up @@ -503,7 +526,7 @@ TEST_CASE("TFT-SUMMONER-V1") {
}
TEST_CASE("VAL-CONTENT-V1") {
std::cout << "TESTING VAL-CONTENT-V1" << '\n';
RiotApiClient test_client(CONFIG);
RiotApiClient test_client(api_key_path, "../test/log_file.txt", logging::LEVEL::DEBUG, true);

json_ptr result;
json doc;
Expand Down