test: align Profile consumers with explicit default

This commit is contained in:
2026-08-30 00:37:52 +09:00
parent 16c0fc704d
commit 22867faa9c
3 changed files with 28 additions and 13 deletions
+15 -11
View File
@@ -1850,7 +1850,7 @@ max_tokens = 3333
} }
#[test] #[test]
fn invalid_ambiguous_and_no_default_diagnostics_include_available_selectors() { fn invalid_and_ambiguous_diagnostics_include_available_selectors() {
let tmp = TempDir::new().unwrap(); let tmp = TempDir::new().unwrap();
let project = tmp.path().join("project"); let project = tmp.path().join("project");
std::fs::create_dir_all(&project).unwrap(); std::fs::create_dir_all(&project).unwrap();
@@ -1868,17 +1868,21 @@ max_tokens = 3333
assert!(invalid.contains("Use `default`, `inherit`")); assert!(invalid.contains("Use `default`, `inherit`"));
assert!(invalid.contains("`project:coder`")); assert!(invalid.contains("`project:coder`"));
let default_error = build_spawn_config_json_for_profile( let default_config: serde_json::Value = serde_json::from_str(
&parent, &build_spawn_config_json_for_profile(
&available, &parent,
&project, &available,
"child", &project,
None, "child",
&scope, None,
SpawnProfileSelector::Default, &scope,
SpawnProfileSelector::Default,
)
.unwrap(),
) )
.unwrap_err(); .unwrap();
assert!(default_error.contains("no default profile is configured")); assert_eq!(default_config["feature"]["sub_worker"]["enabled"], true);
assert_eq!(default_config["feature"]["ticket"]["enabled"], false);
let user_config = tmp.path().join("user-profiles.toml"); let user_config = tmp.path().join("user-profiles.toml");
std::fs::write(&user_config, "[profile]\ncoder = \"user-coder.toml\"\n").unwrap(); std::fs::write(&user_config, "[profile]\ncoder = \"user-coder.toml\"\n").unwrap();
+7 -1
View File
@@ -3740,7 +3740,13 @@ fn builtin_profile_source_archive(
profile: &ProfileSelector, profile: &ProfileSelector,
) -> Result<ProfileSourceArchive, String> { ) -> Result<ProfileSourceArchive, String> {
let selected_profile = match profile { let selected_profile = match profile {
ProfileSelector::Builtin(name) => name.clone(), ProfileSelector::Builtin(name) => {
if name.starts_with("builtin:") {
name.clone()
} else {
format!("builtin:{name}")
}
}
ProfileSelector::Named(name) => { ProfileSelector::Named(name) => {
return Err(format!( return Err(format!(
"embedded runtime does not provide named Profile `{name}`" "embedded runtime does not provide named Profile `{name}`"
+6 -1
View File
@@ -18155,7 +18155,12 @@ mod tests {
}, },
) )
.unwrap(); .unwrap();
assert_eq!(existing.state, WorkerOperationState::Accepted); assert_eq!(
existing.state,
WorkerOperationState::Accepted,
"diagnostics: {:?}",
existing.diagnostics
);
let worker_id = existing.worker.unwrap().worker.worker_id; let worker_id = existing.worker.unwrap().worker.worker_id;
let worker = api let worker = api
.runtime .runtime