From 44bb5fba22a9aed7068ecb074701059add11557e Mon Sep 17 00:00:00 2001 From: ForzenString <964413011@qq.com> Date: Fri, 29 Nov 2024 19:24:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=99=A8=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/mongo/release_version/retrieve.rs | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) 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..e0724384 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),false) => { + doc! { + "platform":to_bson(&plat)?, + "deleted": false + } + } + (None,true)=>{ + doc! {} } - Some(plat) => { + (Some(plat),true)=>{ doc! { "platform":to_bson(&plat)?, - "deleted": deleted } } }) @@ -146,9 +156,19 @@ mod test { mongodb::bson::doc, }; use mongo_migration::Migrator; - + use crate::release_version::retrieve::generate_platform_filter_document; use crate::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() { connect_db_with_migrate::( From 2f3acccba0277858e582339538f76f8ab1558827 Mon Sep 17 00:00:00 2001 From: ForzenString <964413011@qq.com> Date: Fri, 29 Nov 2024 19:26:06 +0800 Subject: [PATCH 2/2] :art: cargo fmt --- .../src/mongo/release_version/retrieve.rs | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) 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 e0724384..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,22 +115,22 @@ where fn generate_platform_filter_document( platform: Option, deleted: bool, ) -> Result { - Ok(match (platform,deleted) { - (None,false) => { + Ok(match (platform, deleted) { + (None, false) => { doc! { "deleted": false } } - (Some(plat),false) => { + (Some(plat), false) => { doc! { "platform":to_bson(&plat)?, "deleted": false } } - (None,true)=>{ + (None, true) => { doc! {} } - (Some(plat),true)=>{ + (Some(plat), true) => { doc! { "platform":to_bson(&plat)?, } @@ -156,19 +156,23 @@ mod test { mongodb::bson::doc, }; use mongo_migration::Migrator; - use crate::release_version::retrieve::generate_platform_filter_document; - 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"); + 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() { connect_db_with_migrate::(