Skip to content

Commit

Permalink
Fix test-resources directory not created when running clean build (#529)
Browse files Browse the repository at this point in the history
Fixes #528
  • Loading branch information
melix authored Sep 2, 2022
1 parent b4f8195 commit 1ebf1fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ private TaskProvider<StartTestResourcesService> createStartServiceTask(Configura
TaskContainer tasks,
Provider<RegularFile> portFile,
Path stopFile,
Provider<Boolean> isStandalone, Provider<Directory> cdsDir) {
Provider<Boolean> isStandalone,
Provider<Directory> cdsDir) {
return tasks.register(START_TEST_RESOURCES_SERVICE_INTERNAL, StartTestResourcesService.class, task -> {
task.setOnlyIf(t -> config.getEnabled().get());
task.getPortFile().convention(portFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public void startServer(ServerUtils.ProcessParameters processParameters) throws
getLogger().lifecycle("Test resources server started in standalone mode. You can stop it by running the " + MicronautTestResourcesPlugin.STOP_TEST_RESOURCES_SERVICE + " task.");
}
String stop = getStandalone().map(v -> String.valueOf(!v)).get();
Files.createDirectories(stopFilePath.getParent());
Files.write(stopFilePath, Collections.singletonList(stop), StandardOpenOption.CREATE);
}
if (Boolean.TRUE.equals(getForeground().get()) || processParameters.isCDSDumpInvocation()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ class ApplicationTestResourcesPluginSpec extends AbstractGradleBuildSpec {
result.output.contains "io.micronaut.testresources.testcontainers.GenericTestContainerProvider"
}

def "creates temp test-resources directory when running 'clean build'"() {
withSample("test-resources/data-mysql")

when:
def result = build 'clean', 'build'

then:
result.task(':test').outcome == TaskOutcome.SUCCESS
result.output.contains "Loaded 2 test resources resolvers"
result.output.contains "io.micronaut.testresources.mysql.MySQLTestResourceProvider"
result.output.contains "io.micronaut.testresources.testcontainers.GenericTestContainerProvider"
}

def "fails if test resources support is disabled"() {
withSample("test-resources/data-mysql")
withTestResourcesConfiguration """
Expand Down

0 comments on commit 1ebf1fd

Please sign in to comment.