@@ -136,6 +136,22 @@ describe("RedisContainer", { timeout: 240_000 }, () => {
136136 client . destroy ( ) ;
137137 } ) ;
138138
139+ it ( "should start redis-stack with custom env" , async ( ) => {
140+ const container = new RedisContainer ( REDISSTACK_IMAGE ) . withEnvironment ( { REDIS_ARGS : "--loglevel verbose" } ) ;
141+ const startedContainer = await container . start ( ) ;
142+
143+ // @ts -expect-error - accessing private property for testing
144+ expect ( container . createOpts . Env ) . toEqual ( [ "REDIS_ARGS=--loglevel verbose" ] ) ;
145+
146+ const client = createClient ( { url : startedContainer . getConnectionUrl ( ) } ) ;
147+ await client . connect ( ) ;
148+
149+ await client . set ( "key" , "val" ) ;
150+ expect ( await client . get ( "key" ) ) . toBe ( "val" ) ;
151+
152+ client . destroy ( ) ;
153+ } ) ;
154+
139155 it ( "should start redis with custom command and keeping default args" , async ( ) => {
140156 const sourcePath = fs . mkdtempSync ( "redis-" ) ;
141157
@@ -162,4 +178,25 @@ describe("RedisContainer", { timeout: 240_000 }, () => {
162178 client . destroy ( ) ;
163179 fs . rmSync ( sourcePath , { force : true , recursive : true } ) ;
164180 } ) ;
181+
182+ it ( "should start redis-stack with custom env and keeping default args" , async ( ) => {
183+ const sourcePath = fs . mkdtempSync ( "redis-" ) ;
184+
185+ const container = new RedisContainer ( REDISSTACK_IMAGE )
186+ . withEnvironment ( { REDIS_ARGS : "--loglevel verbose" } )
187+ . withPersistence ( sourcePath ) ;
188+ const startedContainer = await container . start ( ) ;
189+
190+ // @ts -expect-error - accessing private property for testing
191+ expect ( container . createOpts . Env ) . toEqual ( [ "REDIS_ARGS=--loglevel verbose --save 1 1 --appendonly yes" ] ) ;
192+
193+ const client = createClient ( { url : startedContainer . getConnectionUrl ( ) } ) ;
194+ await client . connect ( ) ;
195+
196+ await client . set ( "key" , "val" ) ;
197+ expect ( await client . get ( "key" ) ) . toBe ( "val" ) ;
198+
199+ client . destroy ( ) ;
200+ fs . rmSync ( sourcePath , { force : true , recursive : true } ) ;
201+ } ) ;
165202} ) ;
0 commit comments