From 0eaccea6937747630508ab4e3a2196e183ff4c2e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 18 Jun 2024 12:21:58 +1000 Subject: [PATCH] Add MariaDB tests by extended the MySQL class Add MariaDB tests into github workflow using a port mapping to the 3307 port to deconflict with the MySQL service. --- .github/workflows/main.yml | 9 +++++++++ tests/Dapper.Tests/Providers/MariaDBTests.cs | 14 ++++++++++++++ tests/Dapper.Tests/Providers/MySQLTests.cs | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/Dapper.Tests/Providers/MariaDBTests.cs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a31c48f20..5b0bec217 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,14 @@ jobs: env: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: test + mariadb: + image: mariadb + ports: + - 3307:3306/tcp + env: + MARIADB_ROOT_PASSWORD: root + MARIADB_DATABASE: test + options: --health-cmd "healthcheck.sh --connect --innodb_initialized" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Checkout code uses: actions/checkout@v1 @@ -49,5 +57,6 @@ jobs: OLEDBConnectionString: Provider=SQLOLEDB;Server=tcp:localhost,${{ job.services.sqlserver.ports[1433] }};Database=tempdb;User Id=sa;Password=Password.; PostgesConnectionString: Server=localhost;Port=${{ job.services.postgres.ports[5432] }};Database=test;User Id=postgres;Password=postgres; SqlServerConnectionString: Server=tcp:localhost,${{ job.services.sqlserver.ports[1433] }};Database=tempdb;User Id=sa;Password=Password.; + MariaDBConnectionString: Server=localhost;Port=${{ job.services.mariadb.ports[3306] }};Uid=root;Pwd=root;Database=test;Allow User Variables=true - name: .NET Lib Pack run: dotnet pack Build.csproj --no-build -c Release /p:PackageOutputPath=%CD%\.nupkgs /p:CI=true diff --git a/tests/Dapper.Tests/Providers/MariaDBTests.cs b/tests/Dapper.Tests/Providers/MariaDBTests.cs new file mode 100644 index 000000000..b45a0c3d2 --- /dev/null +++ b/tests/Dapper.Tests/Providers/MariaDBTests.cs @@ -0,0 +1,14 @@ +namespace Dapper.Tests +{ + /// + /// If Docker Desktop is installed, run the following command to start a container suitable for the tests. + /// + /// docker run -d -p 3306:3306 --name Dapper.Tests.MariaDB -e MARIADB_DATABASE=tests -e MARIADB_USER=test -e MARIADB_PASSWORD=pass -e MARIADB_ROOT_PASSWORD=pass mariadb + /// + /// + public sealed class MariaDBProvider : MySqlProvider + { + public override string GetConnectionString() => + GetConnectionString("MariaDBConnectionString", "Server=localhost;Database=tests;Uid=test;Pwd=pass;"); + } +} diff --git a/tests/Dapper.Tests/Providers/MySQLTests.cs b/tests/Dapper.Tests/Providers/MySQLTests.cs index 0a6abef69..a585f266a 100644 --- a/tests/Dapper.Tests/Providers/MySQLTests.cs +++ b/tests/Dapper.Tests/Providers/MySQLTests.cs @@ -13,7 +13,7 @@ namespace Dapper.Tests /// docker run -d -p 3306:3306 --name Dapper.Tests.MySQL -e MYSQL_DATABASE=tests -e MYSQL_USER=test -e MYSQL_PASSWORD=pass -e MYSQL_ROOT_PASSWORD=pass mysql /// /// - public sealed class MySqlProvider : DatabaseProvider + public class MySqlProvider : DatabaseProvider { public override DbProviderFactory Factory => MySqlConnector.MySqlConnectorFactory.Instance; public override string GetConnectionString() =>