|
29 | 29 |
|
30 | 30 | import org.junit.jupiter.api.BeforeEach;
|
31 | 31 | import org.junit.jupiter.api.Test;
|
| 32 | +import org.junit.jupiter.api.extension.ExtendWith; |
32 | 33 | import org.junit.jupiter.api.io.TempDir;
|
33 | 34 |
|
34 | 35 | import org.springframework.aot.AotDetector;
|
|
38 | 39 | import org.springframework.boot.docker.compose.core.DockerComposeFile;
|
39 | 40 | import org.springframework.boot.docker.compose.core.RunningService;
|
40 | 41 | import org.springframework.boot.docker.compose.lifecycle.DockerComposeProperties.Readiness.Wait;
|
| 42 | +import org.springframework.boot.test.system.CapturedOutput; |
| 43 | +import org.springframework.boot.test.system.OutputCaptureExtension; |
41 | 44 | import org.springframework.context.ApplicationContext;
|
42 | 45 | import org.springframework.context.ApplicationListener;
|
43 | 46 | import org.springframework.context.support.GenericApplicationContext;
|
|
59 | 62 | * @author Phillip Webb
|
60 | 63 | * @author Scott Frederick
|
61 | 64 | */
|
| 65 | +@ExtendWith(OutputCaptureExtension.class) |
62 | 66 | class DockerComposeLifecycleManagerTests {
|
63 | 67 |
|
64 | 68 | @TempDir
|
@@ -365,6 +369,21 @@ void startPublishesEvent() {
|
365 | 369 | assertThat(event.getRunningServices()).isEqualTo(this.runningServices);
|
366 | 370 | }
|
367 | 371 |
|
| 372 | + @Test |
| 373 | + void shouldLogIfServicesAreAlreadyRunning(CapturedOutput output) { |
| 374 | + setUpRunningServices(); |
| 375 | + this.lifecycleManager.start(); |
| 376 | + assertThat(output).contains("There are already Docker Compose services running, skipping startup"); |
| 377 | + } |
| 378 | + |
| 379 | + @Test |
| 380 | + void shouldNotLogIfThereAreNoServicesRunning(CapturedOutput output) { |
| 381 | + given(this.dockerCompose.hasDefinedServices()).willReturn(true); |
| 382 | + given(this.dockerCompose.getRunningServices()).willReturn(Collections.emptyList()); |
| 383 | + this.lifecycleManager.start(); |
| 384 | + assertThat(output).doesNotContain("There are already Docker Compose services running, skipping startup"); |
| 385 | + } |
| 386 | + |
368 | 387 | private void setUpRunningServices() {
|
369 | 388 | setUpRunningServices(true);
|
370 | 389 | }
|
|
0 commit comments