feat: def interface to del traffic pattern

This commit is contained in:
realaravinth 2022-05-14 18:56:41 +05:30
parent 2dd18897b0
commit 5270ced600
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
2 changed files with 18 additions and 0 deletions

View file

@ -201,6 +201,13 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase {
username: &str,
captcha_key: &str,
) -> DBResult<TrafficPattern>;
/// Delete traffic configuration
async fn delete_traffic_pattern(
&self,
username: &str,
captcha_key: &str,
) -> DBResult<()>;
}
#[derive(Default, PartialEq, Serialize, Deserialize, Clone, Debug)]

View file

@ -15,6 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! Test utilities
use crate::errors::*;
use crate::prelude::*;
/// test all database functions
@ -147,6 +148,16 @@ pub async fn database_works<'a, T: MCDatabase>(
tp
);
// delete traffic pattern
db.delete_traffic_pattern(p.username, c.key).await.unwrap();
assert!(
matches!(
db.get_traffic_pattern(p.username, c.key).await,
Err(DBError::TrafficPatternNotFound)
),
"deletion successful; traffic pattern no longer exists"
);
// add captcha levels
db.add_captcha_levels(p.username, c.key, l).await.unwrap();