diff --git a/db/db-core/src/lib.rs b/db/db-core/src/lib.rs index 1629835c..a3d6b871 100644 --- a/db/db-core/src/lib.rs +++ b/db/db-core/src/lib.rs @@ -201,6 +201,13 @@ pub trait MCDatabase: std::marker::Send + std::marker::Sync + CloneSPDatabase { username: &str, captcha_key: &str, ) -> DBResult; + + /// Delete traffic configuration + async fn delete_traffic_pattern( + &self, + username: &str, + captcha_key: &str, + ) -> DBResult<()>; } #[derive(Default, PartialEq, Serialize, Deserialize, Clone, Debug)] diff --git a/db/db-core/src/tests.rs b/db/db-core/src/tests.rs index b1d185f2..f8888912 100644 --- a/db/db-core/src/tests.rs +++ b/db/db-core/src/tests.rs @@ -15,6 +15,7 @@ * along with this program. If not, see . */ //! 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();