19
19
import org .junit .Test ;
20
20
21
21
public class RatchetFromTest extends GradleIntegrationTest {
22
+ private static final String TEST_PATH = "src/markdown/test.md" ;
23
+
22
24
@ Test
23
25
public void singleProjectExhaustive () throws Exception {
24
26
Git git = Git .init ().setDirectory (rootFolder ()).call ();
@@ -29,13 +31,13 @@ public void singleProjectExhaustive() throws Exception {
29
31
"spotless {" ,
30
32
" ratchetFrom 'baseline'" ,
31
33
" format 'misc', {" ,
32
- " target '*.md'" ,
34
+ " target 'src/markdown/ *.md'" ,
33
35
" custom 'lowercase', { str -> str.toLowerCase() }" ,
34
36
" bumpThisNumberIfACustomStepChanges(1)" ,
35
37
" }" ,
36
38
"}" );
37
- setFile ("test.md" ).toContent ("HELLO" );
38
- git .add ().addFilepattern ("test.md" ).call ();
39
+ setFile (TEST_PATH ).toContent ("HELLO" );
40
+ git .add ().addFilepattern (TEST_PATH ).call ();
39
41
git .commit ().setMessage ("Initial state" ).call ();
40
42
// tag this initial state as the baseline for spotless to ratchet from
41
43
git .tag ().setName ("baseline" ).call ();
@@ -45,41 +47,41 @@ public void singleProjectExhaustive() throws Exception {
45
47
assertClean ();
46
48
47
49
// but if we change it so that it is not clean, spotless will now say it is dirty
48
- setFile ("test.md" ).toContent ("HELLO WORLD" );
50
+ setFile (TEST_PATH ).toContent ("HELLO WORLD" );
49
51
assertDirty ();
50
52
gradleRunner ().withArguments ("spotlessApply" ).build ();
51
- assertFile ("test.md" ).hasContent ("hello world" );
53
+ assertFile (TEST_PATH ).hasContent ("hello world" );
52
54
53
55
// but if we make it unchanged again, it goes back to being clean
54
- setFile ("test.md" ).toContent ("HELLO" );
56
+ setFile (TEST_PATH ).toContent ("HELLO" );
55
57
assertClean ();
56
58
57
59
// and if we make the index dirty
58
- setFile ("test.md" ).toContent ("HELLO WORLD" );
59
- git .add ().addFilepattern ("test.md" ).call ();
60
+ setFile (TEST_PATH ).toContent ("HELLO WORLD" );
61
+ git .add ().addFilepattern (TEST_PATH ).call ();
60
62
{
61
63
// and the content dirty in the same way, then it's dirty
62
64
assertDirty ();
63
65
// if we make the content something else dirty, then it's dirty
64
- setFile ("test.md" ).toContent ("HELLO MOM" );
66
+ setFile (TEST_PATH ).toContent ("HELLO MOM" );
65
67
assertDirty ();
66
68
// if we make the content unchanged, even though index it and index are dirty, then it's clean
67
- setFile ("test.md" ).toContent ("HELLO" );
69
+ setFile (TEST_PATH ).toContent ("HELLO" );
68
70
assertClean ();
69
71
// if we delete the file, but it's still in the index, then it's clean
70
- setFile ("test.md" ).deleted ();
72
+ setFile (TEST_PATH ).deleted ();
71
73
assertClean ();
72
74
}
73
75
// if we remove the file from the index
74
- git .rm ().addFilepattern ("test.md" ).setCached (true ).call ();
76
+ git .rm ().addFilepattern (TEST_PATH ).setCached (true ).call ();
75
77
{
76
78
// and it's gone in real life too, then it's clean
77
79
assertClean ();
78
80
// if the content is there and unchanged, then it's clean
79
- setFile ("test.md" ).toContent ("HELLO" );
81
+ setFile (TEST_PATH ).toContent ("HELLO" );
80
82
assertClean ();
81
83
// if the content is dirty, then it's dirty
82
- setFile ("test.md" ).toContent ("HELLO WORLD" );
84
+ setFile (TEST_PATH ).toContent ("HELLO WORLD" );
83
85
assertDirty ();
84
86
}
85
87
0 commit comments