Skip to content

Commit

Permalink
refactor: we use a lot of sync calls in unit test. bypass the depreca…
Browse files Browse the repository at this point in the history
…ted warning for now by using the sync template directly. I don't want to touch this with a ten foot pole right now as this is a whole world of callback hell
  • Loading branch information
braindigitalis committed Oct 14, 2024
1 parent 6c7b112 commit 283d9c5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/unittest/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
.set_user_limit(99);
dpp::channel createdChannel;
try {
createdChannel = bot.channel_create_sync(channel1);
createdChannel = dpp::sync<dpp::channel>(&bot, &dpp::cluster::channel_create, channel1);
} catch (dpp::rest_exception &exception) {
set_test(VOICE_CHANNEL_CREATE, false);
}
Expand All @@ -2075,7 +2075,7 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
}
}
try {
dpp::channel edited = bot.channel_edit_sync(createdChannel);
dpp::channel edited = dpp::sync<dpp::channel>(&bot, &dpp::cluster::channel_edit, createdChannel);
if (edited.name == "foobar2" && edited.user_limit == 2) {
set_test(VOICE_CHANNEL_EDIT, true);
}
Expand All @@ -2085,7 +2085,7 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b

// delete the voice channel
try {
bot.channel_delete_sync(createdChannel.id);
dpp::sync<dpp::channel>(&bot, &dpp::cluster::channel_delete, createdChannel.id);
set_test(VOICE_CHANNEL_DELETE, true);
} catch (dpp::rest_exception &exception) {
set_test(VOICE_CHANNEL_DELETE, false);
Expand Down Expand Up @@ -2280,7 +2280,7 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
r.colour = dpp::colors::moon_yellow;
dpp::role createdRole;
try {
createdRole = bot.role_create_sync(r);
createdRole = dpp::sync<dpp::role>(&bot, &dpp::cluster::role_create, r);
if (createdRole.name == r.name &&
createdRole.has_move_members() &&
createdRole.flags & dpp::r_mentionable &&
Expand All @@ -2294,15 +2294,15 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
createdRole.name = "Test-Role-Edited";
createdRole.colour = dpp::colors::light_sea_green;
try {
dpp::role edited = bot.role_edit_sync(createdRole);
dpp::role edited = dpp::sync<dpp::role>(&bot, &dpp::cluster::role_edit, createdRole);
if (createdRole.id == edited.id && edited.name == "Test-Role-Edited") {
set_test(ROLE_EDIT, true);
}
} catch (dpp::rest_exception &exception) {
set_test(ROLE_EDIT, false);
}
try {
bot.role_delete_sync(TEST_GUILD_ID, createdRole.id);
dpp::sync<dpp::role>(&bot, &dpp::cluster::role_delete, TEST_GUILD_ID, createdRole.id);
set_test(ROLE_DELETE, true);
} catch (dpp::rest_exception &exception) {
set_test(ROLE_DELETE, false);
Expand Down Expand Up @@ -2335,7 +2335,7 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b

set_test(USER_GET_CACHED_PRESENT, false);
try {
dpp::user_identified u = bot.user_get_cached_sync(TEST_USER_ID);
dpp::user_identified u = dpp::sync<dpp::user_identified>(&bot, &dpp::cluster::user_get_cached, TEST_USER_ID);
set_test(USER_GET_CACHED_PRESENT, (u.id == TEST_USER_ID));
}
catch (const std::exception&) {
Expand All @@ -2350,7 +2350,7 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
* If this becomes not true any more, we'll pick another well known
* user ID.
*/
dpp::user_identified u = bot.user_get_cached_sync(90339695967350784);
dpp::user_identified u = dpp::sync<dpp::user_identified>(&bot, &dpp::cluster::user_get_cached, 90339695967350784);
set_test(USER_GET_CACHED_ABSENT, (u.id == dpp::snowflake(90339695967350784)));
}
catch (const std::exception&) {
Expand Down

0 comments on commit 283d9c5

Please sign in to comment.