Skip to content

Commit 5acd236

Browse files
committed
Test that no .gradle directories are created in subprojects (#23)
1 parent 3b6caa7 commit 5acd236

File tree

6 files changed

+107
-0
lines changed

6 files changed

+107
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package io.miret.etienne.gradle.sass;
2+
3+
import com.github.tomakehurst.wiremock.WireMockServer;
4+
import com.google.common.collect.ImmutableList;
5+
import org.assertj.core.api.SoftAssertions;
6+
import org.assertj.core.api.junit.jupiter.InjectSoftAssertions;
7+
import org.assertj.core.api.junit.jupiter.SoftAssertionsExtension;
8+
import org.gradle.testkit.runner.GradleRunner;
9+
import org.junit.jupiter.api.BeforeEach;
10+
import org.junit.jupiter.api.Test;
11+
import org.junit.jupiter.api.extension.ExtendWith;
12+
import org.junit.jupiter.api.io.TempDir;
13+
14+
import java.io.IOException;
15+
import java.nio.file.Path;
16+
import java.util.List;
17+
18+
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
19+
import static com.github.tomakehurst.wiremock.client.WireMock.get;
20+
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
21+
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
22+
import static io.miret.etienne.gradle.sass.Utils.copy;
23+
import static io.miret.etienne.gradle.sass.Utils.createArchive;
24+
import static java.util.Collections.singletonMap;
25+
26+
/**
27+
* Test applying this plugin in multiple subprojects
28+
* instead of only the root project.
29+
*/
30+
@ExtendWith(SoftAssertionsExtension.class)
31+
public class MultipleApplyTest {
32+
33+
@TempDir
34+
Path projectDir;
35+
36+
@InjectSoftAssertions
37+
private SoftAssertions softly;
38+
39+
private WireMockServer server;
40+
41+
@BeforeEach
42+
void startAndSetupWiremockServer () throws IOException {
43+
server = new WireMockServer(options().dynamicPort());
44+
server.start();
45+
server.stubFor(get(urlMatching("/42.0/dart-sass-.*"))
46+
.willReturn(aResponse()
47+
.withStatus(200)
48+
.withBody(createArchive())
49+
)
50+
);
51+
}
52+
53+
@BeforeEach
54+
void setupProject() throws IOException {
55+
List<String> projectResources = ImmutableList.of(
56+
"a/build.gradle",
57+
"b/build.gradle",
58+
"c/build.gradle",
59+
"build.gradle",
60+
"settings.gradle"
61+
);
62+
copy("/io/miret/etienne/gradle/sass/multiple-apply", projectResources, projectDir);
63+
}
64+
65+
@Test
66+
void should_not_create_dot_gradle_directories_in_subprojects() {
67+
GradleRunner runner = GradleRunner.create();
68+
runner.withPluginClasspath();
69+
runner.withEnvironment(singletonMap("URL", server.baseUrl()));
70+
runner.withArguments("installSass");
71+
runner.withProjectDir(projectDir.toFile());
72+
runner.build();
73+
74+
softly.assertThat(projectDir.resolve("a/.gradle")).doesNotExist();
75+
softly.assertThat(projectDir.resolve("b/.gradle")).doesNotExist();
76+
softly.assertThat(projectDir.resolve("c/.gradle")).doesNotExist();
77+
}
78+
79+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
id 'io.miret.etienne.sass'
3+
}
4+
5+
sass {
6+
version = '42.0'
7+
baseUrl = System.getenv("URL")
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
id 'io.miret.etienne.sass'
3+
}
4+
5+
sass {
6+
version = '42.0'
7+
baseUrl = System.getenv("URL")
8+
}

src/functionalTest/resources/io/miret/etienne/gradle/sass/multiple-apply/build.gradle

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
id 'io.miret.etienne.sass'
3+
}
4+
5+
sass {
6+
version = '42.0'
7+
baseUrl = System.getenv("URL")
8+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rootProject.name = 'test-multiple-apply'
2+
include 'a'
3+
include 'b'
4+
include 'c'

0 commit comments

Comments
 (0)