diff --git a/persistence/dao/ceobe-operate/src/mongo/release_version/retrieve.rs b/persistence/dao/ceobe-operate/src/mongo/release_version/retrieve.rs index 085235d3..18d9170d 100644 --- a/persistence/dao/ceobe-operate/src/mongo/release_version/retrieve.rs +++ b/persistence/dao/ceobe-operate/src/mongo/release_version/retrieve.rs @@ -115,14 +115,24 @@ where fn generate_platform_filter_document( platform: Option, deleted: bool, ) -> Result { - Ok(match platform { - None => { - doc! {"deleted": deleted} + Ok(match (platform, deleted) { + (None, false) => { + doc! { + "deleted": false + } } - Some(plat) => { + (Some(plat), false) => { + doc! { + "platform":to_bson(&plat)?, + "deleted": false + } + } + (None, true) => { + doc! {} + } + (Some(plat), true) => { doc! { "platform":to_bson(&plat)?, - "deleted": deleted } } }) @@ -147,7 +157,21 @@ mod test { }; use mongo_migration::Migrator; - use crate::ToCeobeOperation; + use crate::{ + release_version::retrieve::generate_platform_filter_document, + ToCeobeOperation, + }; + + #[test] + fn test_deleted_filter() { + let doc = generate_platform_filter_document(Some(Desktop), false) + .expect("Err"); + assert_eq!(doc, doc! {"platform": "desktop","deleted":false}); + + let doc = generate_platform_filter_document(Some(Desktop), true) + .expect("err"); + assert_eq!(doc, doc! {"platform": "desktop"}) + } #[tokio::test] async fn test_retrieve_version() {