Fix some actions

This commit is contained in:
Adrian Woźniak 2022-11-08 16:44:16 +01:00
parent b70a464afe
commit 2f0a43c8ef
No known key found for this signature in database
GPG Key ID: 0012845A89C7352B
2 changed files with 13 additions and 17 deletions

View File

@ -1,7 +1,6 @@
use std::collections::HashSet; use std::collections::HashSet;
use channels::carts::{self, active_shopping_cart, modify_item, Error}; use channels::carts::{self, active_shopping_cart, modify_item, Error};
use model::ShoppingCartItem;
use crate::db::*; use crate::db::*;
@ -28,12 +27,7 @@ macro_rules! end_t {
}; };
} }
pub async fn modify_item( pub async fn modify_item(msg: modify_item::Input, db: Database) -> modify_item::Output {
msg: carts::modify_item::Input,
db: Database,
) -> carts::modify_item::Output {
use channels::carts::modify_item::Output;
let mut t = begin_t!(db); let mut t = begin_t!(db);
let dbm = EnsureActiveShoppingCart { let dbm = EnsureActiveShoppingCart {
@ -245,11 +239,9 @@ pub async fn modify_cart(
} }
pub async fn active_shopping_cart( pub async fn active_shopping_cart(
input: carts::active_shopping_cart::Input, input: active_shopping_cart::Input,
db: Database, db: Database,
) -> carts::active_shopping_cart::Output { ) -> active_shopping_cart::Output {
use carts::active_shopping_cart::Output;
tracing::debug!("{:?}", input); tracing::debug!("{:?}", input);
let mut t = begin_t!(db); let mut t = begin_t!(db);

View File

@ -115,7 +115,8 @@ mod tests {
ctx.clone(), ctx.clone(),
config.clone(), config.clone(),
) )
.await; .await
.unwrap();
create_index( create_index(
create_index::Input::new( create_index::Input::new(
"2", "2",
@ -127,7 +128,8 @@ mod tests {
ctx.clone(), ctx.clone(),
config.clone(), config.clone(),
) )
.await; .await
.unwrap();
create_index( create_index(
create_index::Input::new( create_index::Input::new(
"3", "3",
@ -139,13 +141,15 @@ mod tests {
ctx.clone(), ctx.clone(),
config.clone(), config.clone(),
) )
.await; .await
.unwrap();
create_index( create_index(
create_index::Input::new("4", "zółta kukurydza", "check_lookup", "default", Lang::Pol), create_index::Input::new("4", "zółta kukurydza", "check_lookup", "default", Lang::Pol),
ctx.clone(), ctx.clone(),
config.clone(), config.clone(),
) )
.await; .await
.unwrap();
let search_res: search::Output = search( let search_res: search::Output = search(
search::Input::new("pomidor", "check_lookup", "default", Lang::Pol), search::Input::new("pomidor", "check_lookup", "default", Lang::Pol),
@ -162,13 +166,13 @@ mod tests {
.await; .await;
{ {
let mut res = search_res.found.unwrap(); let mut res = search_res.unwrap().found;
res.sort(); res.sort();
assert_eq!(res, vec!["1".to_string(), "3".to_string()]); assert_eq!(res, vec!["1".to_string(), "3".to_string()]);
} }
{ {
let mut res = suggest_res.found.unwrap(); let mut res = suggest_res.unwrap().found;
res.sort(); res.sort();
assert_eq!(res, vec!["pomarańczowa".to_string(), "pomidor".to_string()]); assert_eq!(res, vec!["pomarańczowa".to_string(), "pomidor".to_string()]);
} }