Skip to content

Commit

Permalink
Merge pull request #218 from Enraged-Dun-Cookie-Development-Team/feat…
Browse files Browse the repository at this point in the history
…/union-version

fix 修复扯回版本过滤器异常
  • Loading branch information
Goodjooy authored Nov 29, 2024
2 parents 956e82b + 2f3accc commit 46f6aed
Showing 1 changed file with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,24 @@ where
fn generate_platform_filter_document(
platform: Option<ReleasePlatform>, deleted: bool,
) -> Result<Document> {
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
}
}
})
Expand All @@ -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() {
Expand Down

0 comments on commit 46f6aed

Please sign in to comment.