diff --git a/apps/ai-game-creator-shell/src-tauri/src/tests/configuration.rs b/apps/ai-game-creator-shell/src-tauri/src/tests/configuration.rs index 8b517b021..adb540bc2 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/tests/configuration.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/tests/configuration.rs @@ -1195,15 +1195,23 @@ fn fallback_template_read_stays_on_snapshot_channel_outside_runtime_dir() { "{\n \"llm\": { \"model\": \"fallback-template-model\" }\n}\n", ) .expect("write fallback template"); - let _guard = clear_test_runtime_config_dir(); + // 设置一个与模板无关的 runtime dir,让分类断言真正覆盖"按路径归属"而非 + // "runtime dir 为 None 时恒 false"的全局开关。 + let runtime_root = unique_project_path(); + fs::create_dir_all(&runtime_root).expect("unrelated runtime config dir"); + let _guard = use_test_runtime_config_dir(runtime_root.clone()); // 仓库旁边的回退模板是共享输入,读取绝不能走会收紧 owner/DACL 的私有通道。 assert!(!game_creator_config_path_is_runtime_managed(&template)); + assert!(game_creator_config_path_is_runtime_managed( + &runtime_root.join(GAME_CREATOR_CONFIG_FILE_NAME) + )); let content = read_game_creator_config_file(&template).expect("read fallback template"); assert!(content .expect("fallback template content") .contains("fallback-template-model")); fs::remove_dir_all(root).ok(); + fs::remove_dir_all(runtime_root).ok(); } #[test] diff --git a/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs b/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs index fc5a2a45b..e2c15a956 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/tests/mod.rs @@ -1327,20 +1327,6 @@ fn use_test_runtime_config_dir(path: PathBuf) -> TestRuntimeConfigDirGuard { } } -fn clear_test_runtime_config_dir() -> TestRuntimeConfigDirGuard { - let lock = TEST_CONFIG_LOCK - .lock() - .unwrap_or_else(|poisoned| poisoned.into_inner()); - let previous = game_creator_runtime_config_dir(); - *game_creator_runtime_config_dir_lock() - .lock() - .expect("runtime config dir lock") = None; - TestRuntimeConfigDirGuard { - _lock: lock, - previous, - } -} - fn assert_task_status(manifest: &Value, task_id: &str, status: &str) { let task = manifest["tasks"] .as_array()