Skip to content

Commit 72d8e65

Browse files
committed
test: add single-entry multiline inline table insertion test
Adds an explicit test reproducing the issue from PR #5655 comment where inserting into a single-entry multiline inline table without a trailing comma could produce malformatted output. The fix already handles this case correctly. https://claude.ai/code/session_01FT59TTz4yRy3DPwbREE82u
1 parent 2564e55 commit 72d8e65

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

crates/pixi_manifest/src/toml/document.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,4 +489,34 @@ dependencies = {
489489
}
490490
"#);
491491
}
492+
493+
/// Reproduces the bug from https://github.com/prefix-dev/pixi/pull/5655#issuecomment-4040362659
494+
/// where inserting into a single-entry multiline inline table without a
495+
/// trailing comma produces `{ numpy = "*"\n, pydantic = ... }`.
496+
#[test]
497+
fn test_insert_into_multiline_inline_table_single_entry() {
498+
let toml = r#"
499+
[feature.test]
500+
dependencies = {
501+
numpy = "*"
502+
}
503+
"#;
504+
let mut manifest = TomlDocument::new(DocumentMut::from_str(toml).unwrap());
505+
manifest
506+
.insert_into_inline_table(
507+
&["feature", "test", "dependencies"],
508+
"pydantic",
509+
toml_edit::Value::from(">=2.12.5,<3"),
510+
)
511+
.unwrap();
512+
513+
insta::assert_snapshot!(manifest.0.to_string(), @r#"
514+
515+
[feature.test]
516+
dependencies = {
517+
numpy = "*",
518+
pydantic = ">=2.12.5,<3"
519+
}
520+
"#);
521+
}
492522
}

0 commit comments

Comments
 (0)