Skip to content

Commit 871c04f

Browse files
authored
Merge branch 'main' into with_env_file
2 parents e6ed27f + 4912725 commit 871c04f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

core/testcontainers/core/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def get_logs(self) -> tuple[bytes, bytes]:
194194
raise ContainerStartException("Container should be started before getting logs")
195195
return self._container.logs(stderr=False), self._container.logs(stdout=False)
196196

197-
def exec(self, command) -> tuple[int, bytes]:
197+
def exec(self, command: Union[str, list[str]]) -> tuple[int, bytes]:
198198
if not self._container:
199199
raise ContainerStartException("Container should be started before executing a command")
200200
return self._container.exec_run(command)

modules/mssql/testcontainers/mssql/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def _configure(self) -> None:
5252

5353
@wait_container_is_ready(AssertionError)
5454
def _connect(self) -> None:
55-
status, _ = self.exec(f"/opt/mssql-tools/bin/sqlcmd -U {self.username} -P {self.password} -Q 'SELECT 1'")
55+
status, _ = self.exec(
56+
["bash", "-c", '/opt/mssql-tools*/bin/sqlcmd -U "$SQLSERVER_USER" -P "$SA_PASSWORD" -Q \'SELECT 1\' -C']
57+
)
5658
assert status == 0, "Cannot run 'SELECT 1': container is not ready"
5759

5860
def get_connection_url(self) -> str:

modules/mssql/tests/test_mssql.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ def test_docker_run_azure_sql_edge():
2525
assert row[0] == "MSSQLSERVER"
2626

2727

28-
# This is a feature in the generic DbContainer class
28+
def test_microsoft_changes_the_mssql_tools_folder_name():
29+
with SqlServerContainer("mcr.microsoft.com/mssql/server:2019-latest") as mssql:
30+
engine = sqlalchemy.create_engine(mssql.get_connection_url())
31+
with engine.begin() as connection:
32+
result = connection.execute(sqlalchemy.text("select @@servicename"))
33+
for row in result:
34+
assert row[0] == "MSSQLSERVER"
35+
36+
37+
# This is a feature in the generic DbContainer class,
2938
# but it can't be tested on its own
30-
# so is tested in various database modules:
31-
# - mysql / mariadb
32-
# - postgresql
33-
# - sqlserver
34-
# - mongodb
3539
def test_quoted_password():
3640
user = "SA"
3741
# spaces seem to cause issues?

0 commit comments

Comments
 (0)