@@ -4,7 +4,6 @@ import { randomUuid } from "../common/uuid";
44import { PullPolicy } from "../utils/pull-policy" ;
55import {
66 checkEnvironmentContainerIsHealthy ,
7- composeContainerName ,
87 getDockerEventStream ,
98 getRunningContainerNames ,
109 getVolumeNames ,
@@ -24,7 +23,7 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
2423 await using startedEnvironment = await new DockerComposeEnvironment ( fixtures , "docker-compose.yml" ) . up ( ) ;
2524
2625 await Promise . all (
27- [ await composeContainerName ( "container" ) , await composeContainerName ( "another_container" ) ] . map (
26+ [ "container-1" , "another_container-1" ] . map (
2827 async ( containerName ) => await checkEnvironmentContainerIsHealthy ( startedEnvironment , containerName )
2928 )
3029 ) ;
@@ -43,7 +42,7 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
4342 it ( "should work with buildkit" , async ( ) => {
4443 const buildkitFixtures = path . resolve ( fixtures , "docker-compose-with-buildkit" ) ;
4544 await using startedEnvironment = await new DockerComposeEnvironment ( buildkitFixtures , "docker-compose.yml" ) . up ( ) ;
46- await checkEnvironmentContainerIsHealthy ( startedEnvironment , await composeContainerName ( "container" ) ) ;
45+ await checkEnvironmentContainerIsHealthy ( startedEnvironment , "container-1" ) ;
4746 } ) ;
4847 }
4948
@@ -63,12 +62,12 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
6362 it ( "should use pull policy for specific service" , async ( ) => {
6463 const env = new DockerComposeEnvironment ( fixtures , "docker-compose-with-many-services.yml" ) ;
6564
66- await using _ = await env . up ( [ "service_2 " ] ) ;
65+ await using _ = await env . up ( [ "service-b " ] ) ;
6766
6867 {
6968 await using dockerEventStream = await getDockerEventStream ( ) ;
7069 const dockerPullEventPromise = waitForDockerEvent ( dockerEventStream . events , "pull" ) ;
71- await using _ = await env . withPullPolicy ( PullPolicy . alwaysPull ( ) ) . up ( [ "service_2 " ] ) ;
70+ await using _ = await env . withPullPolicy ( PullPolicy . alwaysPull ( ) ) . up ( [ "service-b " ] ) ;
7271 await dockerPullEventPromise ;
7372 }
7473 } ) ;
@@ -80,7 +79,7 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
8079 "docker-compose.yml" ,
8180 "docker-compose-update.yml" ,
8281 ] ) . up ( ) ;
83- await using container = startedEnvironment . getContainer ( await composeContainerName ( "container" ) ) ;
82+ await using container = startedEnvironment . getContainer ( "container-1" ) ;
8483
8584 const url = `http://${ container . getHost ( ) } :${ container . getMappedPort ( 8080 ) } ` ;
8685 const response = await fetch ( `${ url } /env` ) ;
@@ -94,17 +93,17 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
9493 . withDefaultWaitStrategy ( Wait . forHealthCheck ( ) )
9594 . up ( ) ;
9695
97- await checkEnvironmentContainerIsHealthy ( startedEnvironment , await composeContainerName ( "container" ) ) ;
96+ await checkEnvironmentContainerIsHealthy ( startedEnvironment , "container-1" ) ;
9897 } ) ;
9998
10099 it ( "should support log message wait strategy" , async ( ) => {
101100 await using startedEnvironment = await new DockerComposeEnvironment ( fixtures , "docker-compose.yml" )
102- . withWaitStrategy ( await composeContainerName ( "container" ) , Wait . forLogMessage ( "Listening on port 8080" ) )
103- . withWaitStrategy ( await composeContainerName ( "another_container" ) , Wait . forLogMessage ( "Listening on port 8080" ) )
101+ . withWaitStrategy ( "container-1" , Wait . forLogMessage ( "Listening on port 8080" ) )
102+ . withWaitStrategy ( "another_container-1" , Wait . forLogMessage ( "Listening on port 8080" ) )
104103 . up ( ) ;
105104
106105 await Promise . all (
107- [ await composeContainerName ( "container" ) , await composeContainerName ( "another_container" ) ] . map (
106+ [ "container-1" , "another_container-1" ] . map (
108107 async ( containerName ) => await checkEnvironmentContainerIsHealthy ( startedEnvironment , containerName )
109108 )
110109 ) ;
@@ -125,10 +124,10 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
125124
126125 it ( "should support health check wait strategy" , async ( ) => {
127126 await using startedEnvironment = await new DockerComposeEnvironment ( fixtures , "docker-compose-with-healthcheck.yml" )
128- . withWaitStrategy ( await composeContainerName ( "container" ) , Wait . forHealthCheck ( ) )
127+ . withWaitStrategy ( "container-1" , Wait . forHealthCheck ( ) )
129128 . up ( ) ;
130129
131- await checkEnvironmentContainerIsHealthy ( startedEnvironment , await composeContainerName ( "container" ) ) ;
130+ await checkEnvironmentContainerIsHealthy ( startedEnvironment , "container-1" ) ;
132131 } ) ;
133132
134133 it . sequential ( "should warn when no started containers match configured wait strategy names" , async ( ) => {
@@ -154,20 +153,20 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
154153 it ( "should support failing health check wait strategy" , async ( ) => {
155154 await expect (
156155 new DockerComposeEnvironment ( fixtures , "docker-compose-with-healthcheck-unhealthy.yml" )
157- . withWaitStrategy ( await composeContainerName ( "container" ) , Wait . forHealthCheck ( ) )
156+ . withWaitStrategy ( "container-1" , Wait . forHealthCheck ( ) )
158157 . up ( )
159158 ) . rejects . toThrow ( `Health check failed: unhealthy` ) ;
160159 } ) ;
161160
162161 it ( "should stop the container when the health check wait strategy times out" , async ( ) => {
163162 await expect (
164163 new DockerComposeEnvironment ( fixtures , "docker-compose-with-healthcheck-with-start-period.yml" )
165- . withWaitStrategy ( await composeContainerName ( "container" ) , Wait . forHealthCheck ( ) )
164+ . withWaitStrategy ( "container-1" , Wait . forHealthCheck ( ) )
166165 . withStartupTimeout ( 0 )
167166 . up ( )
168167 ) . rejects . toThrow ( `Health check not healthy after 0ms` ) ;
169168
170- expect ( await getRunningContainerNames ( ) ) . not . toContain ( "container_1 " ) ;
169+ expect ( await getRunningContainerNames ( ) ) . not . toContain ( "container-1 " ) ;
171170 } ) ;
172171
173172 it ( "should remove volumes when downing an environment" , async ( ) => {
@@ -189,7 +188,7 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
189188 . up ( ) ;
190189
191190 await Promise . all (
192- [ await composeContainerName ( "container" ) , await composeContainerName ( "another_container" ) ] . map (
191+ [ "container-1" , "another_container-1" ] . map (
193192 async ( containerName ) => await checkEnvironmentContainerIsHealthy ( startedEnvironment , containerName )
194193 )
195194 ) ;
@@ -200,7 +199,7 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
200199 . withEnvironment ( { ENV_VAR : "ENV_VAR_VALUE" } )
201200 . up ( ) ;
202201
203- await using container = startedEnvironment . getContainer ( await composeContainerName ( "container" ) ) ;
202+ await using container = startedEnvironment . getContainer ( "container-1" ) ;
204203 const response = await fetch ( `http://${ container . getHost ( ) } :${ container . getMappedPort ( 8080 ) } /env` ) ;
205204 const responseBody = ( await response . json ( ) ) as { [ key : string ] : string } ;
206205 expect ( responseBody [ "ENV_VAR" ] ) . toBe ( "ENV_VAR_VALUE" ) ;
@@ -218,11 +217,11 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
218217 await using startedEnvironment = await new DockerComposeEnvironment (
219218 fixtures ,
220219 "docker-compose-with-many-services.yml"
221- ) . up ( [ "service_2 " ] ) ;
220+ ) . up ( [ "service-b " ] ) ;
222221
223- await checkEnvironmentContainerIsHealthy ( startedEnvironment , await composeContainerName ( "service_2" ) ) ;
224- expect ( ( ) => startedEnvironment . getContainer ( "service_1 " ) ) . toThrow (
225- `Cannot get container "service_1 " as it is not running`
222+ await checkEnvironmentContainerIsHealthy ( startedEnvironment , "service-b-1" ) ;
223+ expect ( ( ) => startedEnvironment . getContainer ( "service-a " ) ) . toThrow (
224+ `Cannot get container "service-a " as it is not running`
226225 ) ;
227226 } ) ;
228227
@@ -244,7 +243,7 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
244243
245244 await using startedEnvironment = await new DockerComposeEnvironment ( overrideFixtures , "docker-compose.yml" ) . up ( ) ;
246245
247- await using container = startedEnvironment . getContainer ( await composeContainerName ( "container" ) ) ;
246+ await using container = startedEnvironment . getContainer ( "container-1" ) ;
248247 const response = await fetch ( `http://${ container . getHost ( ) } :${ container . getMappedPort ( 8080 ) } /env` ) ;
249248 const responseBody = ( await response . json ( ) ) as { [ key : string ] : string } ;
250249 expect ( responseBody [ "ENV_VAR" ] ) . toBe ( "default" ) ;
@@ -257,7 +256,7 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
257256 . withEnvironmentFile ( ".env.override" )
258257 . up ( ) ;
259258
260- await using container = startedEnvironment . getContainer ( await composeContainerName ( "container" ) ) ;
259+ await using container = startedEnvironment . getContainer ( "container-1" ) ;
261260 const response = await fetch ( `http://${ container . getHost ( ) } :${ container . getMappedPort ( 8080 ) } /env` ) ;
262261 const responseBody = ( await response . json ( ) ) as { [ key : string ] : string } ;
263262 expect ( responseBody [ "ENV_VAR" ] ) . toBe ( "override" ) ;
@@ -269,7 +268,7 @@ describe("DockerComposeEnvironment", { timeout: 180_000 }, () => {
269268 . up ( ) ;
270269
271270 await Promise . all (
272- [ await composeContainerName ( "container" ) , await composeContainerName ( "another_container" ) ] . map (
271+ [ "container-1" , "another_container-1" ] . map (
273272 async ( containerName ) => await checkEnvironmentContainerIsHealthy ( startedEnvironment , containerName )
274273 )
275274 ) ;
0 commit comments