@@ -83,7 +83,7 @@ describe("GenericContainer reuse", () => {
8383 await container1 . stop ( ) ;
8484 } ) ;
8585
86- it ( "should create a new container when an existing reusable container has stopped" , async ( ) => {
86+ it ( "should create a new container when an existing reusable container has stopped and is removed " , async ( ) => {
8787 const container1 = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
8888 . withName ( "there_can_only_be_one" )
8989 . withExposedPorts ( 8080 )
@@ -102,6 +102,25 @@ describe("GenericContainer reuse", () => {
102102 await container2 . stop ( ) ;
103103 } ) ;
104104
105+ it ( "should reuse container when an existing reusable container has stopped but not removed" , async ( ) => {
106+ const container1 = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
107+ . withName ( "there_can_only_be_one" )
108+ . withExposedPorts ( 8080 )
109+ . withReuse ( )
110+ . start ( ) ;
111+ await container1 . stop ( { remove : false } ) ;
112+
113+ const container2 = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
114+ . withName ( "there_can_only_be_one" )
115+ . withExposedPorts ( 8080 )
116+ . withReuse ( )
117+ . start ( ) ;
118+ await checkContainerIsHealthy ( container2 ) ;
119+
120+ expect ( container1 . getId ( ) ) . toBe ( container2 . getId ( ) ) ;
121+ await container2 . stop ( ) ;
122+ } ) ;
123+
105124 it ( "should keep the labels passed in when a new reusable container is created" , async ( ) => {
106125 const container = await new GenericContainer ( "cristianrgreco/testcontainer:1.1.14" )
107126 . withName ( "there_can_only_be_one" )
0 commit comments