File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ export class RedisContainer extends GenericContainer {
3232 return this ;
3333 }
3434
35+ protected override async containerStarted ( container : StartedTestContainer ) : Promise < void > {
36+ if ( this . initialImportScriptFile ) {
37+ await this . importInitialData ( container ) ;
38+ }
39+ }
40+
3541 public override async start ( ) : Promise < StartedRedisContainer > {
3642 this . withCommand ( [
3743 "redis-server" ,
@@ -60,7 +66,7 @@ export class RedisContainer extends GenericContainer {
6066 return startedRedisContainer ;
6167 }
6268
63- private async importInitialData ( container : StartedRedisContainer ) {
69+ private async importInitialData ( container : StartedTestContainer ) {
6470 const re = await container . exec ( `/tmp/import.sh ${ this . password } ` ) ;
6571 if ( re . exitCode != 0 || re . output . includes ( "ERR" ) )
6672 throw Error ( `Could not import initial data from ${ this . initialImportScriptFile } : ${ re . output } ` ) ;
Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ export class ValkeyContainer extends GenericContainer {
3131 return this ;
3232 }
3333
34+ protected override async containerStarted ( container : StartedTestContainer ) : Promise < void > {
35+ if ( this . initialImportScriptFile ) {
36+ await this . importInitialData ( container ) ;
37+ }
38+ }
39+
3440 public override async start ( ) : Promise < StartedValkeyContainer > {
3541 this . withCommand ( [
3642 "valkey-server" ,
@@ -54,12 +60,11 @@ export class ValkeyContainer extends GenericContainer {
5460 } ,
5561 ] ) ;
5662 }
57- const startedContainer = new StartedValkeyContainer ( await super . start ( ) , this . password ) ;
58- if ( this . initialImportScriptFile ) await this . importInitialData ( startedContainer ) ;
59- return startedContainer ;
63+
64+ return new StartedValkeyContainer ( await super . start ( ) , this . password ) ;
6065 }
6166
62- private async importInitialData ( container : StartedValkeyContainer ) {
67+ private async importInitialData ( container : StartedTestContainer ) {
6368 const re = await container . exec ( `/tmp/import.sh ${ this . password || "" } ` ) ;
6469 if ( re . exitCode !== 0 || re . output . includes ( "ERR" ) ) {
6570 throw Error ( `Could not import initial data from ${ this . initialImportScriptFile } : ${ re . output } ` ) ;
You can’t perform that action at this time.
0 commit comments