mirror of https://github.com/AMT-Cheif/drift.git
Scaffold MariaDb integration tests
This commit is contained in:
parent
23b7b60656
commit
18946f5580
|
@ -166,6 +166,13 @@ jobs:
|
|||
--health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
mariadb:
|
||||
image: mariadb
|
||||
env:
|
||||
MARIADB_ROOT_PASSWORD: password
|
||||
MARIADB_DATABASE: database
|
||||
ports:
|
||||
- 3306:3306
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ./.github/actions/prepare
|
||||
|
|
|
@ -5,14 +5,14 @@ import 'package:mysql_client/mysql_client.dart';
|
|||
|
||||
void main() async {
|
||||
final mariadb = MariaDBDatabase(
|
||||
endpoint: MySQLConnectionPool(
|
||||
host: '127.0.0.1',
|
||||
pool: MySQLConnectionPool(
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
userName: 'root',
|
||||
password: 'Password123!',
|
||||
databaseName: 'mdb',
|
||||
maxConnections: 10,
|
||||
secure: false, // if true - TLS will be used, if false - ordinary TCL
|
||||
password: 'password',
|
||||
databaseName: 'database',
|
||||
maxConnections: 1,
|
||||
secure: false,
|
||||
),
|
||||
logStatements: true,
|
||||
);
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
@experimental
|
||||
library drift.mariadb;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
export 'src/mariadb_database.dart';
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:drift/backends.dart';
|
||||
import 'package:mysql_client/mysql_client.dart';
|
||||
|
||||
/// A drift database implementation that talks to a mariadb database.
|
||||
class MariaDBDatabase extends DelegatedDatabase {
|
||||
MariaDBDatabase({
|
||||
required MySQLConnectionPool endpoint,
|
||||
required MySQLConnectionPool pool,
|
||||
bool isSequential = true,
|
||||
bool logStatements = false,
|
||||
}) : super(
|
||||
_MariaDelegate(() => endpoint, true),
|
||||
_MariaDelegate(() => pool, true),
|
||||
isSequential: isSequential,
|
||||
logStatements: logStatements,
|
||||
);
|
||||
|
@ -40,7 +39,7 @@ class _MariaDelegate extends DatabaseDelegate {
|
|||
MySQLConnectionPool? _openedSession;
|
||||
|
||||
@override
|
||||
TransactionDelegate get transactionDelegate => const NoTransactionDelegate(
|
||||
TransactionDelegate get transactionDelegate => NoTransactionDelegate(
|
||||
start: 'START TRANSACTION',
|
||||
commit: 'COMMIT',
|
||||
rollback: 'ROLLBACK',
|
||||
|
|
|
@ -3,12 +3,15 @@ description: Mariadb support for drift.
|
|||
version: 1.0.0
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0-0 <3.0.0'
|
||||
sdk: '>=3.0.0 <4.0.0'
|
||||
|
||||
dependencies:
|
||||
drift: ^2.0.0
|
||||
meta: ^1.9.1
|
||||
mysql_client: ^0.0.27
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^2.0.0
|
||||
test: ^1.21.0
|
||||
drift_testcases:
|
||||
path: ../integration_tests/drift_testcases
|
||||
|
|
|
@ -1,6 +1,41 @@
|
|||
import 'package:drift_mariadb/drift_mariadb.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:drift_testcases/tests.dart';
|
||||
import 'package:mysql_client/mysql_client.dart';
|
||||
|
||||
class MariaDbExecutor extends TestExecutor {
|
||||
@override
|
||||
bool get supportsReturning => true;
|
||||
|
||||
@override
|
||||
bool get supportsNestedTransactions => true;
|
||||
|
||||
@override
|
||||
DatabaseConnection createConnection() {
|
||||
final pool = MySQLConnectionPool(
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
userName: 'root',
|
||||
password: 'password',
|
||||
databaseName: 'database',
|
||||
maxConnections: 1,
|
||||
secure: false,
|
||||
);
|
||||
|
||||
return DatabaseConnection(MariaDBDatabase(pool: pool, logStatements: true));
|
||||
}
|
||||
|
||||
@override
|
||||
Future clearDatabaseAndClose(Database db) async {
|
||||
await db.customStatement('DROP DATABASE database;');
|
||||
await db.customStatement('CREATE DATABASE database;');
|
||||
|
||||
await db.close();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteData() async {}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// TODO: Setup tests
|
||||
runAllTests(MariaDbExecutor());
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ description: Postgres support for drift
|
|||
version: 1.0.0
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0-0 <3.0.0'
|
||||
sdk: '>=2.12.0-0 <4.0.0'
|
||||
|
||||
dependencies:
|
||||
collection: ^1.16.0
|
||||
|
|
|
@ -9,6 +9,7 @@ packages:
|
|||
- sqlparser
|
||||
- examples/*
|
||||
- extras/benchmarks
|
||||
- extras/drift_mariadb
|
||||
- extras/drift_postgres
|
||||
- extras/encryption
|
||||
- extras/integration_tests/*
|
||||
|
|
|
@ -6,6 +6,12 @@ dart pub upgrade
|
|||
dart test
|
||||
popd
|
||||
|
||||
pushd extras/drift_mariadb
|
||||
echo "Running integration tests with MariaDb"
|
||||
dart pub upgrade
|
||||
dart test
|
||||
popd
|
||||
|
||||
pushd examples/with_built_value
|
||||
echo "Running build runner in with_built_value"
|
||||
dart pub upgrade
|
||||
|
|
Loading…
Reference in New Issue