Skip to content

Commit

Permalink
remove dpp::sync from unit tests, we no longer test it
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Nov 18, 2024
1 parent 8542b08 commit 1169268
Showing 1 changed file with 32 additions and 38 deletions.
70 changes: 32 additions & 38 deletions src/unittest/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2011,48 +2011,42 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b
.set_name("voice1")
.add_permission_overwrite(TEST_GUILD_ID, dpp::ot_role, 0, dpp::p_view_channel)
.set_user_limit(99);
dpp::channel createdChannel;
try {
createdChannel = dpp::sync<dpp::channel>(&bot, &dpp::cluster::channel_create, channel1);
} catch (dpp::rest_exception &exception) {
set_test(VOICE_CHANNEL_CREATE, false);
}
if (createdChannel.name == channel1.name &&
createdChannel.user_limit == 99 &&
createdChannel.name == "voice1") {
for (auto overwrite: createdChannel.permission_overwrites) {
if (overwrite.id == TEST_GUILD_ID && overwrite.type == dpp::ot_role && overwrite.deny == dpp::p_view_channel) {
set_test(VOICE_CHANNEL_CREATE, true);
}
}

// edit the voice channel
createdChannel.set_name("foobar2");
createdChannel.set_user_limit(2);
for (auto overwrite: createdChannel.permission_overwrites) {
if (overwrite.id == TEST_GUILD_ID) {
overwrite.deny.set(0);
overwrite.allow.set(dpp::p_view_channel);
}
bot.channel_create(channel1, [&bot,channel1](const auto& response) {
if (response.is_error()) {
set_test(VOICE_CHANNEL_CREATE, false);
return;
}
try {
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);
dpp::channel createdChannel = std::get<dpp::channel>(response.value);
if (createdChannel.name == channel1.name && createdChannel.user_limit == 99 && createdChannel.name == "voice1") {
for (auto overwrite: createdChannel.permission_overwrites) {
if (overwrite.id == TEST_GUILD_ID && overwrite.type == dpp::ot_role && overwrite.deny == dpp::p_view_channel) {
set_test(VOICE_CHANNEL_CREATE, true);
break;
}
}
} catch (dpp::rest_exception &exception) {
set_test(VOICE_CHANNEL_EDIT, false);
}

// delete the voice channel
try {
dpp::sync<dpp::confirmation>(&bot, &dpp::cluster::channel_delete, createdChannel.id);
set_test(VOICE_CHANNEL_DELETE, true);
} catch (dpp::rest_exception &exception) {
bot.log(dpp::ll_warning, "Exception: " + std::string(exception.what()));
set_test(VOICE_CHANNEL_DELETE, false);
// edit the voice channel
createdChannel.set_name("foobar2");
createdChannel.set_user_limit(2);
for (auto overwrite: createdChannel.permission_overwrites) {
if (overwrite.id == TEST_GUILD_ID) {
overwrite.deny.set(0);
overwrite.allow.set(dpp::p_view_channel);
}
}
bot.channel_edit(createdChannel, [&bot,createdChannel](const auto& response) {
if (response.is_error()) {
set_test(VOICE_CHANNEL_EDIT, false);
return;
}
dpp::channel edited = std::get<dpp::channel>(response.value);
set_test(VOICE_CHANNEL_EDIT, (edited.name == "foobar2" && edited.user_limit == 2));
bot.channel_delete(createdChannel.id,[](const auto& response) {
set_test(VOICE_CHANNEL_DELETE, !response.is_error());
});
});
}
}
});
}

set_test(FORUM_CREATION, false);
Expand Down

0 comments on commit 1169268

Please sign in to comment.