Skip to content

Commit 6fc0c6a

Browse files
committed
Add a test
1 parent af7bcb3 commit 6fc0c6a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/test_utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
from textwrap import dedent
3-
from pipeline_migration.utils import YAMLStyle, dump_yaml, BlockSequenceIndentation
3+
from pipeline_migration.utils import YAMLStyle, dump_yaml, load_yaml, BlockSequenceIndentation
44

55
YAML_EXAMPLE_0_INDENT = """\
66
apiVersion: tekton.dev/v1
@@ -122,3 +122,14 @@ def test_dump_yaml_with_style(style, data, expected_yaml, tmp_path):
122122
yaml_file = tmp_path / "file.yaml"
123123
dump_yaml(yaml_file, data, style=style)
124124
assert yaml_file.read_text() == expected_yaml
125+
126+
127+
@pytest.mark.parametrize("yaml_content", [YAML_EXAMPLE_0_INDENT, YAML_EXAMPLE_2_INDENTS])
128+
def test_dump_same_yaml_with_consistent_indentation_formatting(yaml_content, tmp_path):
129+
yaml_file = tmp_path / "file.yaml"
130+
yaml_file.write_text(yaml_content)
131+
style = YAMLStyle.detect(yaml_file)
132+
doc = load_yaml(yaml_file)
133+
new_file = tmp_path / "new.yaml"
134+
dump_yaml(new_file, doc, style)
135+
assert yaml_file.read_text() == new_file.read_text()

0 commit comments

Comments
 (0)