From f63d3c4df4a59d815608c0378d3661739beaaf63 Mon Sep 17 00:00:00 2001 From: Vemund Santi Date: Wed, 3 Apr 2024 13:56:43 +0200 Subject: [PATCH] Update tests with modern tags for mysql. Support more ARM --- modules/mysql/tests/test_mysql.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/mysql/tests/test_mysql.py b/modules/mysql/tests/test_mysql.py index a84df4d1..30c4bdce 100644 --- a/modules/mysql/tests/test_mysql.py +++ b/modules/mysql/tests/test_mysql.py @@ -8,41 +8,41 @@ from testcontainers.mysql import MySqlContainer -@pytest.mark.skipif(is_arm(), reason="mysql container not available for ARM") def test_docker_run_mysql(): - config = MySqlContainer("mysql:5.7.17") + config = MySqlContainer("mysql:8.3.0") with config as mysql: engine = sqlalchemy.create_engine(mysql.get_connection_url()) with engine.begin() as connection: result = connection.execute(sqlalchemy.text("select version()")) for row in result: - assert row[0].startswith("5.7.17") + assert row[0].startswith("8.3.0") @pytest.mark.skipif(is_arm(), reason="mysql container not available for ARM") -def test_docker_run_mysql_8(): - config = MySqlContainer("mysql:8") +def test_docker_run_legacy_mysql(): + config = MySqlContainer("mysql:5.7.44") with config as mysql: engine = sqlalchemy.create_engine(mysql.get_connection_url()) with engine.begin() as connection: result = connection.execute(sqlalchemy.text("select version()")) for row in result: - assert row[0].startswith("8") + assert row[0].startswith("5.7.17") -def test_docker_run_mariadb(): - with MySqlContainer("mariadb:10.6.5").maybe_emulate_amd64() as mariadb: +@pytest.mark.parametrize("version", ["11.3.2", "10.11.7"]) +def test_docker_run_mariadb(version: str): + with MySqlContainer(f"mariadb:{version}") as mariadb: engine = sqlalchemy.create_engine(mariadb.get_connection_url()) with engine.begin() as connection: result = connection.execute(sqlalchemy.text("select version()")) for row in result: - assert row[0].startswith("10.6.5") + assert row[0].startswith(version) def test_docker_env_variables(): with mock.patch.dict("os.environ", MYSQL_USER="demo", MYSQL_DATABASE="custom_db"), MySqlContainer( "mariadb:10.6.5" - ).with_bind_ports(3306, 32785).maybe_emulate_amd64() as container: + ).with_bind_ports(3306, 32785) as container: url = container.get_connection_url() pattern = r"mysql\+pymysql:\/\/demo:test@[\w,.]+:(3306|32785)\/custom_db" assert re.match(pattern, url)