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
+27 -6
View File
@@ -28,7 +28,11 @@ async fn public_content(app: &common::TestApp) -> serde_json::Value {
.send()
.await
.unwrap();
assert_eq!(res.status(), 200, "public content read must be unauthenticated");
assert_eq!(
res.status(),
200,
"public content read must be unauthenticated"
);
res.json().await.unwrap()
}
@@ -59,7 +63,10 @@ async fn home_content_is_public_and_ordered() {
.collect();
let mut sorted = positions.clone();
sorted.sort_unstable();
assert_eq!(positions, sorted, "content must come back in position order");
assert_eq!(
positions, sorted,
"content must come back in position order"
);
}
#[tokio::test]
@@ -83,14 +90,20 @@ async fn admin_replace_round_trips_and_reorders() {
.map(|b| b["image"].as_str().unwrap().to_string())
.collect()
};
assert_eq!(images(&public_content(&app).await), vec!["/mock/a.svg", "/mock/b.svg"]);
assert_eq!(
images(&public_content(&app).await),
vec!["/mock/a.svg", "/mock/b.svg"]
);
// The submitted order decides the stored order and the positions.
let flipped = serde_json::json!([
{"image": "/mock/b.svg", "url": "/collective"},
{"image": "/mock/a.svg", "url": "/seckill"}
]);
assert_eq!(replace(&app, &admin, "banners", flipped).await.status(), 200);
assert_eq!(
replace(&app, &admin, "banners", flipped).await.status(),
200
);
let content = public_content(&app).await;
assert_eq!(images(&content), vec!["/mock/b.svg", "/mock/a.svg"]);
assert_eq!(content["banners"][0]["position"], 0);
@@ -116,7 +129,11 @@ async fn inactive_rows_are_hidden_from_the_public_read() {
.iter()
.map(|b| b["image"].as_str().unwrap())
.collect();
assert_eq!(visible, vec!["/mock/on.svg"], "inactive rows must not be public");
assert_eq!(
visible,
vec!["/mock/on.svg"],
"inactive rows must not be public"
);
// The admin read keeps it, so a disabled block stays editable.
let res = client()
@@ -153,7 +170,11 @@ async fn invalid_entry_is_rejected_without_touching_stored_content() {
.iter()
.map(|b| b["image"].as_str().unwrap())
.collect();
assert_eq!(images, vec!["/mock/keep.svg"], "a rejected list must change nothing");
assert_eq!(
images,
vec!["/mock/keep.svg"],
"a rejected list must change nothing"
);
}
#[tokio::test]