chore(api): apply rustfmt across modules and tests
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
6c1357ec4d
commit
a4ef6ca49e
@@ -173,7 +173,10 @@ async fn inactive_window_falls_back_to_normal_price() {
|
||||
let item = &orders[0]["items"][0];
|
||||
assert_eq!(item["unit_price_minor"], 1000, "normal price applies");
|
||||
assert!(item["flash_sale_item_id"].is_null());
|
||||
assert_eq!(activity_lines(&app, orders[0]["id"].as_str().unwrap()).await, 0);
|
||||
assert_eq!(
|
||||
activity_lines(&app, orders[0]["id"].as_str().unwrap()).await,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -182,7 +185,8 @@ async fn cross_shop_sku_and_overlapping_sessions_are_rejected() {
|
||||
let app = spawn_app().await;
|
||||
let admin = login_admin(&app).await;
|
||||
let (owner_a, shop_a, _product_a, sku_a) = setup_sellable(&app, &admin, "fs-a", 1000, 5).await;
|
||||
let (_owner_b, _shop_b, _product_b, sku_b) = setup_sellable(&app, &admin, "fs-b", 1000, 5).await;
|
||||
let (_owner_b, _shop_b, _product_b, sku_b) =
|
||||
setup_sellable(&app, &admin, "fs-b", 1000, 5).await;
|
||||
let (starts, ends) = active_window();
|
||||
|
||||
let session = create_session(&app, &owner_a, &starts, &ends).await;
|
||||
@@ -195,7 +199,11 @@ async fn cross_shop_sku_and_overlapping_sessions_are_rejected() {
|
||||
// A second overlapping session cannot list the same SKU.
|
||||
let session_two = create_session(&app, &owner_a, &starts, &ends).await;
|
||||
let res = add_item(&app, &owner_a, &session_two, &sku_a, 400, 5, 3).await;
|
||||
assert_eq!(res.status(), 409, "overlapping sale for the same SKU is refused");
|
||||
assert_eq!(
|
||||
res.status(),
|
||||
409,
|
||||
"overlapping sale for the same SKU is refused"
|
||||
);
|
||||
let _ = shop_a;
|
||||
}
|
||||
|
||||
@@ -263,13 +271,12 @@ async fn reserved_stock_admits_one_activity_price() {
|
||||
assert_eq!(reserved, 0, "the single reserved unit is consumed");
|
||||
assert_eq!(sold, 1);
|
||||
|
||||
let activity: i64 = sqlx::query_scalar(
|
||||
"SELECT count(*) FROM order_items WHERE flash_sale_item_id = $1",
|
||||
)
|
||||
.bind(Uuid::parse_str(&item_id).unwrap())
|
||||
.fetch_one(&app.db)
|
||||
.await
|
||||
.unwrap();
|
||||
let activity: i64 =
|
||||
sqlx::query_scalar("SELECT count(*) FROM order_items WHERE flash_sale_item_id = $1")
|
||||
.bind(Uuid::parse_str(&item_id).unwrap())
|
||||
.fetch_one(&app.db)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(activity, 1, "exactly one line got the activity price");
|
||||
}
|
||||
|
||||
@@ -304,7 +311,10 @@ async fn per_customer_limit_splits_the_line() {
|
||||
.filter(|i| i["flash_sale_item_id"].is_null())
|
||||
.collect();
|
||||
assert_eq!(activity.len(), 1);
|
||||
assert_eq!(activity[0]["qty"], 1, "only the allowance gets the activity price");
|
||||
assert_eq!(
|
||||
activity[0]["qty"], 1,
|
||||
"only the allowance gets the activity price"
|
||||
);
|
||||
assert_eq!(activity[0]["unit_price_minor"], 400);
|
||||
assert_eq!(standard.len(), 1);
|
||||
assert_eq!(standard[0]["qty"], 2);
|
||||
@@ -316,7 +326,10 @@ async fn per_customer_limit_splits_the_line() {
|
||||
let res = checkout_with(&app, &token, HashMap::new()).await;
|
||||
let orders: Vec<serde_json::Value> = res.json().await.unwrap();
|
||||
assert!(orders[0]["items"][0]["flash_sale_item_id"].is_null());
|
||||
assert_eq!(activity_lines(&app, orders[0]["id"].as_str().unwrap()).await, 0);
|
||||
assert_eq!(
|
||||
activity_lines(&app, orders[0]["id"].as_str().unwrap()).await,
|
||||
0
|
||||
);
|
||||
|
||||
let (_, sold) = flash_item_state(&app, &item_id).await;
|
||||
assert_eq!(sold, 1);
|
||||
@@ -330,7 +343,12 @@ async fn coupon_is_rejected_on_a_flash_priced_shop_order() {
|
||||
let (owner, shop, _product, sku) = setup_sellable(&app, &admin, "fs-cp", 1000, 5).await;
|
||||
let (starts, ends) = active_window();
|
||||
let session = create_session(&app, &owner, &starts, &ends).await;
|
||||
assert_eq!(add_item(&app, &owner, &session, &sku, 400, 5, 5).await.status(), 201);
|
||||
assert_eq!(
|
||||
add_item(&app, &owner, &session, &sku, 400, 5, 5)
|
||||
.await
|
||||
.status(),
|
||||
201
|
||||
);
|
||||
|
||||
let template = create_template(&app, &owner, 100, 0).await;
|
||||
let (token, _) = register_customer(&app, "fs-cp").await;
|
||||
@@ -338,7 +356,11 @@ async fn coupon_is_rejected_on_a_flash_priced_shop_order() {
|
||||
|
||||
add_to_cart(&app, &token, &sku, 1).await;
|
||||
let res = checkout_with(&app, &token, HashMap::from([(shop, coupon)])).await;
|
||||
assert_eq!(res.status(), 409, "activity pricing and coupons are exclusive");
|
||||
assert_eq!(
|
||||
res.status(),
|
||||
409,
|
||||
"activity pricing and coupons are exclusive"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -375,7 +397,10 @@ async fn cancel_restores_reserved_stock_and_coupon() {
|
||||
|
||||
for order in &orders {
|
||||
let res = client()
|
||||
.post(app.url(&format!("/api/orders/{}/cancel", order["id"].as_str().unwrap())))
|
||||
.post(app.url(&format!(
|
||||
"/api/orders/{}/cancel",
|
||||
order["id"].as_str().unwrap()
|
||||
)))
|
||||
.bearer_auth(&token)
|
||||
.send()
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user