Skip to content

Commit

Permalink
Merge yaml test for inline comments retention (#4365)
Browse files Browse the repository at this point in the history
* Added test cases to check inline comment retention.

* Updated issue number to check inline comment retention.

---------

Co-authored-by: j0m17kw <[email protected]>
Co-authored-by: Peter Streef <[email protected]>
  • Loading branch information
3 people authored and jevanlingen committed Nov 22, 2024
1 parent d4369f9 commit c8997f3
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions rewrite-yaml/src/test/java/org/openrewrite/yaml/MergeYamlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,37 @@ void mergeEmptyStructureFollowedByCopyValue() {
);
}


@Issue("https://github.com/openrewrite/rewrite/issues/2218")
@Test
void mergePropertiesWithExistingComments() {
rewriteRun(
spec -> spec.recipe(new
MergeYaml(
"$",
//language=yaml
"""
widget:
list:
currentCount: 3
""",
true, null, null
)
),
yaml(
"""
widget:
list:
itemCount: 5 #number of existing items in the list
""",
"""
widget:
list:
itemCount: 5 #number of existing items in the list
currentCount: 3
"""
)

@Test
void addLiteralStyleBlockAtRoot() {
rewriteRun(
Expand Down

0 comments on commit c8997f3

Please sign in to comment.