Skip to content

Yaml/ChangePropertyKey - whitespace quirks #2608

@nmck257

Description

@nmck257

test cases:

    @Test
    void moveSubpropertyOut() {
        rewriteRun(
          spec -> spec.recipe(new ChangePropertyKey("foo.bar", "bar", null, null, null)),
          yaml(
            """
            foo:
              bar:
                prop: val
              other: other-val
            """,
            """
            foo:
              other: other-val
            bar:
              prop: val
            """
          )
        );
    }

    @Test
    void multiDocument() {
        rewriteRun(
          spec -> spec.recipe(new ChangePropertyKey("foo.bar", "bar", null, null, null)),
          yaml(
            """
            a: b
            ---
            foo:
              bar:
                prop: val
            other: other-val
            """,
            """
            a: b
            ---
            other: other-val
            bar:
              prop: val
            """
          )
        );
    }

These cases yield these failures:

expected: "foo:
  other: other-val
bar:
  prop: val"
 but was: "
foo:
  other: other-val
bar:
  prop: val"

...and...

expected: "a: b
---
other: other-val
bar:
  prop: val"
 but was: "a: b
---other: val
bar:
  prop: val"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions