From 0563db5562052a1f508c0684ee5f6ac40aa91c21 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 10 Jun 2023 22:26:15 +0200 Subject: [PATCH] Add tests for permission modification --- tests/channel.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/channel.rs b/tests/channel.rs index 85b019b..8ae8e58 100644 --- a/tests/channel.rs +++ b/tests/channel.rs @@ -1,5 +1,5 @@ mod common; -use chorus::types::{self, Channel}; +use chorus::types::{self, Channel, PermissionFlags, PermissionOverwrite}; #[tokio::test] async fn get_channel() { @@ -54,5 +54,31 @@ async fn modify_channel() { .await .unwrap(); assert_eq!(result.name, Some("beepboop".to_string())); + + let permission_override = PermissionFlags::from_vec(Vec::from([ + PermissionFlags::MANAGE_CHANNELS, + PermissionFlags::MANAGE_MESSAGES, + ])); + let permission_override = PermissionOverwrite { + id: bundle.user.object.id.to_string(), + overwrite_type: "1".to_string(), + allow: permission_override, + deny: "0".to_string(), + }; + + Channel::edit_permissions( + &mut bundle.user, + bundle.channel.id.to_string().as_str(), + permission_override.clone(), + ) + .await; + + Channel::delete_permission( + &mut bundle.user, + bundle.channel.id.to_string().as_str(), + &permission_override.id, + ) + .await; + common::teardown(bundle).await }