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
+31 -12
View File
@@ -13,11 +13,7 @@ async fn list_shops(app: &common::TestApp) -> serde_json::Value {
}
fn find<'a>(shops: &'a serde_json::Value, id: &str) -> Option<&'a serde_json::Value> {
shops
.as_array()
.unwrap()
.iter()
.find(|s| s["id"] == id)
shops.as_array().unwrap().iter().find(|s| s["id"] == id)
}
async fn set_profile(
@@ -45,7 +41,10 @@ async fn shop_without_a_profile_is_still_listed() {
let shops = list_shops(&app).await;
let shop = find(&shops, &shop_id).expect("a shop with no profile must still be listed");
assert!(shop["name"]["en"].is_string());
assert!(shop["logo"].is_null(), "nothing may be invented for a missing profile");
assert!(
shop["logo"].is_null(),
"nothing may be invented for a missing profile"
);
assert!(shop["score_rating"].is_null());
}
@@ -97,7 +96,10 @@ async fn suspended_or_unknown_shops_are_not_public() {
let shop_id = create_shop(&app, &admin, "shop-suspended").await;
let shops = list_shops(&app).await;
let slug = find(&shops, &shop_id).unwrap()["slug"].as_str().unwrap().to_string();
let slug = find(&shops, &shop_id).unwrap()["slug"]
.as_str()
.unwrap()
.to_string();
client()
.put(app.url(&format!("/api/admin/shops/{shop_id}/status")))
@@ -107,7 +109,10 @@ async fn suspended_or_unknown_shops_are_not_public() {
.await
.unwrap();
assert!(find(&list_shops(&app).await, &shop_id).is_none(), "suspended shops are hidden");
assert!(
find(&list_shops(&app).await, &shop_id).is_none(),
"suspended shops are hidden"
);
let res = client()
.get(app.url(&format!("/api/shops/{slug}")))
.send()
@@ -120,7 +125,11 @@ async fn suspended_or_unknown_shops_are_not_public() {
.send()
.await
.unwrap();
assert_eq!(res.status(), 404, "an unknown slug is a 404, not an empty profile");
assert_eq!(
res.status(),
404,
"an unknown slug is a 404, not an empty profile"
);
}
#[tokio::test]
@@ -134,7 +143,10 @@ async fn incomplete_bilingual_text_is_refused_without_writing() {
"company": "Kept Co.",
"notice": {"en": "Original notice", "zh": "原始公告"}
});
assert_eq!(set_profile(&app, &admin, &shop_id, good).await.status(), 200);
assert_eq!(
set_profile(&app, &admin, &shop_id, good).await.status(),
200
);
let bad = serde_json::json!({
"company": "Changed Co.",
@@ -144,7 +156,10 @@ async fn incomplete_bilingual_text_is_refused_without_writing() {
assert_eq!(res.status(), 400, "a label missing zh must be refused");
let shop = find(&list_shops(&app).await, &shop_id).unwrap().clone();
assert_eq!(shop["company"], "Kept Co.", "the rejected write changed nothing");
assert_eq!(
shop["company"], "Kept Co.",
"the rejected write changed nothing"
);
assert_eq!(shop["notice"]["zh"], "原始公告");
}
@@ -160,6 +175,10 @@ async fn profile_writes_require_a_platform_admin() {
let body = serde_json::json!({ "company": "Nope" });
for token in [&owner, &customer] {
let res = set_profile(&app, token, &shop_id, body.clone()).await;
assert_eq!(res.status(), 403, "only platform admins may write a profile");
assert_eq!(
res.status(),
403,
"only platform admins may write a profile"
);
}
}