chore(api): apply rustfmt across modules and tests

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Chengdong Zhang
2026-09-21 18:52:52 +08:00
co-authored by Cursor
parent 6c1357ec4d
commit a4ef6ca49e
46 changed files with 495 additions and 334 deletions
+37 -11
View File
@@ -1,9 +1,9 @@
mod common;
use common::{
add_to_cart, category_id_by_slug, checkout, client, create_product_full, create_product_with_sku,
create_product_with_sku_in_category, create_shop, login_admin, make_shop_owner, pay,
publish_product, register_customer, spawn_app,
add_to_cart, category_id_by_slug, checkout, client, create_product_full,
create_product_with_sku, create_product_with_sku_in_category, create_shop, login_admin,
make_shop_owner, pay, publish_product, register_customer, spawn_app,
};
use serial_test::serial;
@@ -61,7 +61,10 @@ async fn publish_lifecycle_and_public_visibility() {
.await
.unwrap();
assert_eq!(res.status(), 200);
assert_eq!(res.json::<serde_json::Value>().await.unwrap()["status"], "published");
assert_eq!(
res.json::<serde_json::Value>().await.unwrap()["status"],
"published"
);
let res = client().get(app.url("/api/products")).send().await.unwrap();
let list: serde_json::Value = res.json().await.unwrap();
@@ -154,7 +157,10 @@ async fn currency_conversion_math() {
.send()
.await
.unwrap();
assert_eq!(res.json::<serde_json::Value>().await.unwrap()["amount_minor"], 2999);
assert_eq!(
res.json::<serde_json::Value>().await.unwrap()["amount_minor"],
2999
);
// disabled currency rejected
let admin = login_admin(&app).await;
@@ -226,10 +232,22 @@ async fn category_subtree_listing_and_price_sort() {
assert_eq!(res.status(), 200);
let body: serde_json::Value = res.json().await.unwrap();
let listed = listed_ids(&body);
assert!(listed.contains(&leaf), "grandchild product missing from root listing");
assert!(listed.contains(&sibling), "child product missing from root listing");
assert!(!listed.contains(&unrelated), "product from another root category leaked in");
assert_eq!(body["total"], 2, "total must count the subtree, not only the root");
assert!(
listed.contains(&leaf),
"grandchild product missing from root listing"
);
assert!(
listed.contains(&sibling),
"child product missing from root listing"
);
assert!(
!listed.contains(&unrelated),
"product from another root category leaked in"
);
assert_eq!(
body["total"], 2,
"total must count the subtree, not only the root"
);
// A mid-level category covers its own subtree and nothing else.
let res = client()
@@ -355,7 +373,11 @@ async fn brand_filter_and_real_sales() {
.await
.unwrap();
let body: serde_json::Value = res.json().await.unwrap();
assert_eq!(sold(&body, &p_alpha), 0, "pending payment must not count as sold");
assert_eq!(
sold(&body, &p_alpha),
0,
"pending payment must not count as sold"
);
assert_eq!(sold(&body, &p_beta), 0);
// Paying makes the units count, and the sales sort follows them.
@@ -378,7 +400,11 @@ async fn brand_filter_and_real_sales() {
.await
.unwrap();
let body: serde_json::Value = res.json().await.unwrap();
assert_eq!(ids(&body)[0], p_alpha, "sales sort puts the sold product first");
assert_eq!(
ids(&body)[0],
p_alpha,
"sales sort puts the sold product first"
);
// Comments still have no model, so that sort stays refused.
let res = client()