@@ -7,49 +7,45 @@ import { StartedGenericContainer } from "./started-generic-container";
77
88const fixtures = path . resolve ( __dirname , ".." , ".." , "fixtures" , "docker" ) ;
99
10- if ( ! process . env . CI_PODMAN ) {
11- describe ( "GenericContainer wait strategy" , { timeout : 180_000 } , ( ) => {
12- it ( "should use Wait.forListeningPorts if healthcheck is not defined in DOCKERFILE" , async ( ) => {
13- await using container = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
14- . withExposedPorts ( 8080 )
15- . start ( ) ;
16- expect ( ( container as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HostPortWaitStrategy ) ;
17- } ) ;
18- it ( "should use Wait.forHealthCheck if withHealthCheck() explicitly called" , async ( ) => {
19- await using container = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
20- . withExposedPorts ( 8080 )
21- . withHealthCheck ( {
22- test : [ "CMD-SHELL" , "echo 'started' && exit 0" ] ,
23- } )
24- . start ( ) ;
25- expect ( ( container as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HealthCheckWaitStrategy ) ;
26- } ) ;
27- it ( "should use Wait.forHealthCheck if healthcheck is defined in DOCKERFILE" , async ( ) => {
28- const context = path . resolve ( fixtures , "docker-with-health-check" ) ;
29- const genericContainer = await GenericContainer . fromDockerfile ( context ) . build ( ) ;
30- await using startedContainer = await genericContainer . start ( ) ;
31- expect ( ( startedContainer as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf (
32- HealthCheckWaitStrategy
33- ) ;
34- } ) ;
35- it ( "should use same WaitStrategy if it's explicitly defined in withWaitStrategy() even if image defines healthcheck" , async ( ) => {
36- const context = path . resolve ( fixtures , "docker-with-health-check" ) ;
37- const genericContainer = await GenericContainer . fromDockerfile ( context ) . build ( ) ;
38- await using container = await genericContainer
39- . withExposedPorts ( 8080 )
40- . withWaitStrategy ( Wait . forListeningPorts ( ) )
41- . start ( ) ;
42- expect ( ( container as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HostPortWaitStrategy ) ;
43- } ) ;
44- it ( "should use same WaitStrategy if it's explicitly defined in withWaitStrategy() even if withHealthCheck() is called" , async ( ) => {
45- await using container = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
46- . withExposedPorts ( 8080 )
47- . withHealthCheck ( {
48- test : [ "CMD-SHELL" , "echo 'started' && exit 0" ] ,
49- } )
50- . withWaitStrategy ( Wait . forListeningPorts ( ) )
51- . start ( ) ;
52- expect ( ( container as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HostPortWaitStrategy ) ;
53- } ) ;
10+ describe ( "GenericContainer wait strategy" , { timeout : 180_000 } , ( ) => {
11+ it ( "should use Wait.forListeningPorts if healthcheck is not defined in DOCKERFILE" , async ( ) => {
12+ await using container = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
13+ . withExposedPorts ( 8080 )
14+ . start ( ) ;
15+ expect ( ( container as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HostPortWaitStrategy ) ;
5416 } ) ;
55- }
17+ it ( "should use Wait.forHealthCheck if withHealthCheck() explicitly called" , async ( ) => {
18+ await using container = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
19+ . withExposedPorts ( 8080 )
20+ . withHealthCheck ( {
21+ test : [ "CMD-SHELL" , "echo 'started' && exit 0" ] ,
22+ } )
23+ . start ( ) ;
24+ expect ( ( container as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HealthCheckWaitStrategy ) ;
25+ } ) ;
26+ it ( "should use Wait.forHealthCheck if healthcheck is defined in DOCKERFILE" , async ( ) => {
27+ const context = path . resolve ( fixtures , "docker-with-health-check" ) ;
28+ const genericContainer = await GenericContainer . fromDockerfile ( context ) . build ( ) ;
29+ await using startedContainer = await genericContainer . start ( ) ;
30+ expect ( ( startedContainer as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HealthCheckWaitStrategy ) ;
31+ } ) ;
32+ it ( "should use same WaitStrategy if it's explicitly defined in withWaitStrategy() even if image defines healthcheck" , async ( ) => {
33+ const context = path . resolve ( fixtures , "docker-with-health-check" ) ;
34+ const genericContainer = await GenericContainer . fromDockerfile ( context ) . build ( ) ;
35+ await using container = await genericContainer
36+ . withExposedPorts ( 8080 )
37+ . withWaitStrategy ( Wait . forListeningPorts ( ) )
38+ . start ( ) ;
39+ expect ( ( container as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HostPortWaitStrategy ) ;
40+ } ) ;
41+ it ( "should use same WaitStrategy if it's explicitly defined in withWaitStrategy() even if withHealthCheck() is called" , async ( ) => {
42+ await using container = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
43+ . withExposedPorts ( 8080 )
44+ . withHealthCheck ( {
45+ test : [ "CMD-SHELL" , "echo 'started' && exit 0" ] ,
46+ } )
47+ . withWaitStrategy ( Wait . forListeningPorts ( ) )
48+ . start ( ) ;
49+ expect ( ( container as StartedGenericContainer ) [ "getWaitStrategy" ] ( ) ) . toBeInstanceOf ( HostPortWaitStrategy ) ;
50+ } ) ;
51+ } ) ;
0 commit comments