Skip to content

Commit

Permalink
Space Indentation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankag32 committed Feb 11, 2024
1 parent 3a9412f commit bc2318a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 25 deletions.
34 changes: 34 additions & 0 deletions src/unittest/gateway_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,40 @@ void gateway_events_tests(const std::string& token, dpp::cluster& bot) {
bot.on_voice_receive_combined([&](const auto& event) {
});

bot.on_guild_create([&](const dpp::guild_create_t& event) {
dpp::guild* g = event.created;

if (g->id == TEST_GUILD_ID) {
start_test(GUILD_EDIT);
g->set_icon(dpp::i_png, test_image.data(), static_cast<uint32_t>(test_image.size()));
bot.guild_edit(*g, [&bot](const dpp::confirmation_callback_t& result) {
if (result.is_error()) {
set_status(GUILD_EDIT, ts_failed, "guild_edit 1 errored:\n" + result.get_error().human_readable);
return;
}
dpp::guild g = result.get<dpp::guild>();

if (g.get_icon_url().empty()) {
set_status(GUILD_EDIT, ts_failed, "icon not set or not retrieved");
return;
}
g.remove_icon();
bot.guild_edit(g, [&bot](const dpp::confirmation_callback_t& result) {
if (result.is_error()) {
set_status(GUILD_EDIT, ts_failed, "guild_edit 2 errored:\n" + result.get_error().human_readable);
return;
}
const dpp::guild& g = result.get<dpp::guild>();
if (!g.get_icon_url().empty()) {
set_status(GUILD_EDIT, ts_failed, "icon not removed");
return;
}
set_status(GUILD_EDIT, ts_success);
});
});
}
});

std::promise<void> ready_promise;
std::future ready_future = ready_promise.get_future();
bot.on_ready([&](const dpp::ready_t & event) {
Expand Down
53 changes: 28 additions & 25 deletions src/unittest/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ _Pragma("warning( disable : 5105 )"); // 4251 warns when we export classes or st

#ifdef _WIN32
#define SHARED_OBJECT "dpp.dll"
#elif __APPLE__
#define SHARED_OBJECT "libdpp.dylib"
#else
#define SHARED_OBJECT "libdpp.so"
#endif
Expand Down Expand Up @@ -148,6 +150,7 @@ DPP_TEST(FORUM_CHANNEL_GET, "retrieve the created forum channel", tf_online);
DPP_TEST(FORUM_CHANNEL_DELETE, "delete the created forum channel", tf_online);
DPP_TEST(ERRORS, "Human readable error translation", tf_offline);

DPP_TEST(GUILD_EDIT, "cluster::guild_edit", tf_online);
DPP_TEST(GUILD_BAN_CREATE, "cluster::guild_ban_add ban three deleted discord accounts", tf_online);
DPP_TEST(GUILD_BAN_GET, "cluster::guild_get_ban getting one of the banned accounts", tf_online);
DPP_TEST(GUILD_BANS_GET, "cluster::guild_get_bans get bans using the after-parameter", tf_online);
Expand Down Expand Up @@ -307,9 +310,9 @@ inline constexpr bool coro = false;
}); \
}

/**
* @brief Perform a test of a REST base API call with one parameter
*/
/**
* @brief Perform a test of a REST base API call with one parameter
*/
#define twoparam_api_test(func_name, param1, param2, return_type, testname) \
set_test(testname, false); \
if (!offline) { \
Expand All @@ -329,9 +332,9 @@ inline constexpr bool coro = false;
}); \
}

/**
* @brief Perform a test of a REST base API call with one parameter that returns a list
*/
/**
* @brief Perform a test of a REST base API call with one parameter that returns a list
*/
#define singleparam_api_test_list(func_name, param, return_type, testname) \
set_test(testname, false); \
if (!offline) { \
Expand All @@ -351,9 +354,9 @@ inline constexpr bool coro = false;
}); \
}

/**
* @brief Perform a test of a REST base API call with one parameter that returns a list
*/
/**
* @brief Perform a test of a REST base API call with one parameter that returns a list
*/
#define multiparam_api_test_list(func_name, param, return_type, testname) \
set_test(testname, false); \
if (!offline) { \
Expand All @@ -373,9 +376,9 @@ inline constexpr bool coro = false;
}); \
}

/**
* @brief Perform a test of a REST base API call with two parameters
*/
/**
* @brief Perform a test of a REST base API call with two parameters
*/
#define twoparam_api_test_list(func_name, param1, param2, return_type, testname) \
set_test(testname, false); \
if (!offline) { \
Expand All @@ -396,9 +399,9 @@ inline constexpr bool coro = false;
}


/**
* @brief Perform a test of a REST base API call with no parameters
*/
/**
* @brief Perform a test of a REST base API call with no parameters
*/
#define noparam_api_test(func_name, return_type, testname) \
set_test(testname, false); \
if (!offline) { \
Expand All @@ -413,16 +416,16 @@ inline constexpr bool coro = false;
}); \
}

/**
* @brief Sets a test's status (legacy)
*
* @param test The test to set the status of
* @param success If set to true, sets success to true, if set to false and called
* once, sets executed to true, if called twice, also sets success to false.
* This means that before you run the test you should call this function once
* with success set to false, then if/wen the test completes call it again with true.
* If the test fails, call it a second time with false, or not at all.
*/
/**
* @brief Sets a test's status (legacy)
*
* @param test The test to set the status of
* @param success If set to true, sets success to true, if set to false and called
* once, sets executed to true, if called twice, also sets success to false.
* This means that before you run the test you should call this function once
* with success set to false, then if/wen the test completes call it again with true.
* If the test fails, call it a second time with false, or not at all.
*/
void set_test(test_t& test, bool success = false);

/**
Expand Down

0 comments on commit bc2318a

Please sign in to comment.