修 rustfmt:editor_project 新增行按仓库格式折行
- `ensure_editor_image_edit_source_kind_allowed` 的 `is_none_or(...)` 折叠为仓库 rustfmt 口径的换行
- 白名单用例里 `ensure_editor_image_edit_source_kind_allowed(Some("art-spritesheet"), Some("video"))` 断行
- `is_game_creator_resource_editor_generation(Some(&json!({})))` 断言断行
- `let queued_payload: Value = serde_json::from_str(...)` 折行
- 仅 `server-rs/crates/api-server/src/editor_project.rs` 一个文件,无其他文件被 rustfmt 改动
This commit is contained in:
@@ -4146,9 +4146,8 @@ pub(crate) fn ensure_editor_image_edit_source_kind_allowed(
|
||||
) -> Result<(), AppError> {
|
||||
let asset_kind = asset_kind.map(str::trim).filter(|value| !value.is_empty());
|
||||
let media_type = media_type.map(str::trim).filter(|value| !value.is_empty());
|
||||
let asset_kind_allowed = asset_kind.is_none_or(|asset_kind| {
|
||||
EDITOR_IMAGE_EDIT_STATIC_IMAGE_ASSET_KINDS.contains(&asset_kind)
|
||||
});
|
||||
let asset_kind_allowed = asset_kind
|
||||
.is_none_or(|asset_kind| EDITOR_IMAGE_EDIT_STATIC_IMAGE_ASSET_KINDS.contains(&asset_kind));
|
||||
let media_type_allowed = matches!(media_type, None | Some("image"));
|
||||
if asset_kind_allowed && media_type_allowed {
|
||||
return Ok(());
|
||||
@@ -20650,8 +20649,9 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
let error = ensure_editor_image_edit_source_kind_allowed(Some("art-spritesheet"), Some("video"))
|
||||
.expect_err("非静态媒体即使挂着图片类 assetKind 也不得支持快速编辑");
|
||||
let error =
|
||||
ensure_editor_image_edit_source_kind_allowed(Some("art-spritesheet"), Some("video"))
|
||||
.expect_err("非静态媒体即使挂着图片类 assetKind 也不得支持快速编辑");
|
||||
assert_eq!(error.status_code(), StatusCode::BAD_REQUEST);
|
||||
assert_eq!(
|
||||
error.details().and_then(|details| details.get("message")),
|
||||
@@ -20816,7 +20816,9 @@ mod tests {
|
||||
assert!(!is_game_creator_resource_editor_generation(Some(&json!({
|
||||
"source": "editor-agent"
|
||||
}))));
|
||||
assert!(!is_game_creator_resource_editor_generation(Some(&json!({}))));
|
||||
assert!(!is_game_creator_resource_editor_generation(Some(
|
||||
&json!({})
|
||||
)));
|
||||
assert!(!is_game_creator_resource_editor_generation(None));
|
||||
|
||||
// 端到端同口径:AGC 客户端实际发出的 source 必须与 `from_job` 的 consumer 判定一致。
|
||||
@@ -20832,9 +20834,8 @@ mod tests {
|
||||
EditorGenerationQueueResultContext::from_job(&queued_job).consumer,
|
||||
EditorGenerationQueueConsumer::GameCreatorResourceEditor
|
||||
);
|
||||
let queued_payload: Value =
|
||||
serde_json::from_str(queued_job.request_payload_json.as_str())
|
||||
.expect("fixture payload should be JSON");
|
||||
let queued_payload: Value = serde_json::from_str(queued_job.request_payload_json.as_str())
|
||||
.expect("fixture payload should be JSON");
|
||||
assert!(is_game_creator_resource_editor_generation(
|
||||
queued_payload.pointer("/generationInputs")
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user