@@ -68,5 +68,39 @@ describe("LocalStackContainer", () => {
6868 expect ( response ) . toContain ( `http://localstack:${ LOCALSTACK_PORT } ` ) ;
6969 await container . stop ( ) ;
7070 await awsCliInDockerNetwork . stop ( ) ;
71+ await network . stop ( ) ;
72+ } ) ;
73+
74+ it ( "should not override LOCALSTACK_HOST assignment" , async ( ) => {
75+ const container = await new LocalstackContainer ( )
76+ . withEnvironment ( { LOCALSTACK_HOST : "myhost" } )
77+ . withNetworkAliases ( "myalias" )
78+ . start ( ) ;
79+
80+ const { output, exitCode } = await container . exec ( [ "printenv" , "LOCALSTACK_HOST" ] ) ;
81+ expect ( exitCode ) . toBe ( 0 ) ;
82+ expect ( output ) . toContain ( "myhost" ) ;
83+
84+ await container . stop ( ) ;
85+ } ) ;
86+
87+ it ( "should override LOCALSTACK_HOST with last network alias" , async ( ) => {
88+ const container = await new LocalstackContainer ( ) . withNetworkAliases ( "other" , "myalias" ) . start ( ) ;
89+
90+ const { output, exitCode } = await container . exec ( [ "printenv" , "LOCALSTACK_HOST" ] ) ;
91+ expect ( exitCode ) . toBe ( 0 ) ;
92+ expect ( output ) . toContain ( "myalias" ) ;
93+
94+ await container . stop ( ) ;
95+ } ) ;
96+
97+ it ( "should assign LOCALSTACK_HOST to localhost" , async ( ) => {
98+ const container = await new LocalstackContainer ( ) . start ( ) ;
99+
100+ const { output, exitCode } = await container . exec ( [ "printenv" , "LOCALSTACK_HOST" ] ) ;
101+ expect ( exitCode ) . toBe ( 0 ) ;
102+ expect ( output ) . toContain ( "localhost" ) ;
103+
104+ await container . stop ( ) ;
71105 } ) ;
72106} ) ;
0 commit comments