@@ -125,34 +125,34 @@ def test_invalid_configuration_tests(
125125 "psql_user, psql_password, psql_database, psql_admin_password" ,
126126 [
127127 [
128- "-e POSTGRESQL_USER= user" ,
129- "-e POSTGRESQL_PASSWORD= " ,
130- "-e POSTGRESQL_DATABASE= db" ,
131- "-e POSTGRESQL_ADMIN_PASSWORD= admin_pass" ,
128+ "user" ,
129+ "pass " ,
130+ "db" ,
131+ "admin_pass" ,
132132 ],
133133 [
134- "-e POSTGRESQL_USER= user" ,
135- "-e POSTGRESQL_PASSWORD= pass" ,
136- "-e POSTGRESQL_DATABASE= 9invalid" ,
137- "-e POSTGRESQL_ADMIN_PASSWORD= admin_pass" ,
134+ "user" ,
135+ "pass" ,
136+ "9invalid" ,
137+ "admin_pass" ,
138138 ],
139139 [
140- "-e POSTGRESQL_USER= user" ,
141- "-e POSTGRESQL_PASSWORD= pass" ,
142- "-e POSTGRESQL_DATABASE= db" ,
143- "-e POSTGRESQL_ADMIN_PASSWORD= " ,
140+ "user" ,
141+ "pass" ,
142+ "db" ,
143+ "" ,
144144 ],
145145 [
146146 "" ,
147147 "" ,
148148 "" ,
149- '-e POSTGRESQL_ADMIN_PASSWORD= "the @password"' ,
149+ '"the @password"' ,
150150 ],
151151 [
152- '-e POSTGRESQL_USER= "the user"' ,
153- '-e POSTGRESQL_PASSWORD= "the pass"' ,
154- '-e POSTGRESQL_DATABASE= "the db"' ,
155- "-e POSTGRESQL_ADMIN_PASSWORD= " ,
152+ '"the user"' ,
153+ '"the pass"' ,
154+ '"the db"' ,
155+ "" ,
156156 ],
157157 ],
158158 )
@@ -166,15 +166,52 @@ def test_correct_configuration_tests(
166166 """
167167 Test correct configuration combinations for PostgreSQL container.
168168 """
169+ psql_admin_password_arg = ""
170+ psql_user_arg = ""
171+ psql_password_arg = ""
172+ psql_database_arg = ""
173+ if psql_user :
174+ psql_user_arg = f"-e POSTGRESQL_USER={ psql_user } "
175+ if psql_password :
176+ psql_password_arg = f"-e POSTGRESQL_PASSWORD={ psql_password } "
177+ if psql_database :
178+ psql_database_arg = f"-e POSTGRESQL_DATABASE={ psql_database } "
179+ if psql_admin_password :
180+ psql_admin_password_arg = (
181+ f"-e POSTGRESQL_ADMIN_PASSWORD={ psql_admin_password } "
182+ )
183+ container_args = [
184+ psql_user_arg ,
185+ psql_password_arg ,
186+ psql_database_arg ,
187+ psql_admin_password_arg ,
188+ ]
169189 assert self .db .assert_container_creation_succeeds (
170- container_args = [
171- psql_user ,
172- psql_password ,
173- psql_database ,
174- psql_admin_password ,
175- ],
190+ container_args = container_args ,
176191 command = "" ,
177192 )
193+ cid_file_name = "cid_success_test"
194+ assert self .db .create_container (
195+ cid_file_name = cid_file_name ,
196+ container_args = container_args ,
197+ command = "" ,
198+ )
199+ cip = self .db .get_cip (cid_file_name = cid_file_name )
200+ assert cip
201+ if psql_user and psql_password :
202+ assert self .db .test_db_connection (
203+ container_ip = cip ,
204+ username = psql_user ,
205+ password = psql_password ,
206+ database = psql_database ,
207+ )
208+ if psql_admin_password :
209+ assert self .db .test_db_connection (
210+ container_ip = cip ,
211+ username = "postgres" ,
212+ password = psql_admin_password ,
213+ database = psql_database ,
214+ )
178215
179216 def test_configuration_hook (self ):
180217 """
0 commit comments