Skip to content

Commit 3244f2d

Browse files
committed
Add unit-tests
1 parent a89ba3a commit 3244f2d

File tree

6 files changed

+51
-1
lines changed

6 files changed

+51
-1
lines changed

plugin-maven/src/test/java/com/diffplug/spotless/maven/yaml/YamlTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,29 @@
2121

2222
public class YamlTest extends MavenIntegrationHarness {
2323
@Test
24-
public void testFormatJson_WithSimple_defaultConfig() throws Exception {
24+
public void testFormatYaml_WithJackson_defaultConfig_separatorComments() throws Exception {
2525
writePomWithJsonSteps("<yaml><jackson/></yaml>");
2626

2727
setFile("yaml_test.json").toResource("yaml/separator_comments.yaml");
2828
mavenRunner().withArguments("spotless:apply").runNoError().error();
2929
assertFile("yaml_test.json").sameAsResource("yaml/separator_comments.clean.yaml");
3030
}
31+
32+
@Test
33+
public void testFormatYaml_WithJackson_defaultConfig_arrayBrackets() throws Exception {
34+
writePomWithJsonSteps("<yaml><jackson/></yaml>");
35+
36+
setFile("yaml_test.json").toResource("yaml/array_with_bracket.yaml");
37+
mavenRunner().withArguments("spotless:apply").runNoError().error();
38+
assertFile("yaml_test.json").sameAsResource("yaml/array_with_bracket.clean.yaml");
39+
}
40+
41+
@Test
42+
public void testFormatYaml_WithJackson_defaultConfig_multipleComments() throws Exception {
43+
writePomWithJsonSteps("<yaml><jackson/></yaml>");
44+
45+
setFile("yaml_test.json").toResource("yaml/multiple_documents.yaml");
46+
mavenRunner().withArguments("spotless:apply").runNoError().error();
47+
assertFile("yaml_test.json").sameAsResource("yaml/multiple_documents.clean.yaml");
48+
}
3149
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
hr:
3+
- Mark McGwire
4+
# Following node labeled SS
5+
- &SS Sammy Sosa
6+
rbi:
7+
- *SS # Subsequent occurrence
8+
- Ken Griffey
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
hr: [Mark McGwire, Sammy Sosa]
2+
3+
4+
5+
rbi: [Sammy Sosa, Ken Griffey]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
hr:
3+
- Mark McGwire
4+
# Following node labeled SS
5+
- &SS Sammy Sosa
6+
rbi:
7+
- *SS # Subsequent occurrence
8+
- Ken Griffey
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
document: this is document 1
2+
---
3+
4+
document: this is document 2
5+
6+
7+
---
8+
9+
10+
document: this is document 3

testlib/src/main/resources/yaml/separator_comments.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
---
23
hr:
34
- Mark McGwire

0 commit comments

Comments
 (0)