mirror of https://github.com/AMT-Cheif/drift.git
Run migrated tests in strong null safety
This commit is contained in:
parent
896d0f90c7
commit
6c1650151e
|
@ -28,7 +28,7 @@ jobs:
|
|||
# build, test and upload coverage
|
||||
- run: dart run build_runner build --delete-conflicting-outputs
|
||||
working-directory: moor
|
||||
- run: dart --no-sound-null-safety --null-assertions test #-x background_isolate --coverage=coverage
|
||||
- run: dart test #-x background_isolate --coverage=coverage
|
||||
working-directory: moor
|
||||
# - uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
|
|
|
@ -129,10 +129,10 @@ class Value<T> {
|
|||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is Value && present == other.present && value == other.value;
|
||||
other is Value && present == other.present && _value == other._value;
|
||||
|
||||
@override
|
||||
int get hashCode => present.hashCode ^ value.hashCode;
|
||||
int get hashCode => present.hashCode ^ _value.hashCode;
|
||||
}
|
||||
|
||||
/// Serializer responsible for mapping atomic types from and to json.
|
||||
|
|
|
@ -146,23 +146,23 @@ class Migrator {
|
|||
|
||||
for (final row in schemaQuery) {
|
||||
final type = row.readString('type');
|
||||
final sql = row.readString('sql');
|
||||
final sql = row.read<String?>('sql');
|
||||
final name = row.readString('name');
|
||||
|
||||
if (sql == null) {
|
||||
// These indexes are created by sqlite to enforce different kinds of
|
||||
// special constraints.
|
||||
// They do not have any SQL create statement as they are created
|
||||
// automatically by the constraints on the table.
|
||||
// They can not be re-created and need to be skipped.
|
||||
assert(name.startsWith('sqlite_autoindex'));
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'trigger':
|
||||
case 'view':
|
||||
createAffected.add(sql);
|
||||
break;
|
||||
case 'index':
|
||||
if (name.startsWith('sqlite_autoindex')) {
|
||||
// These indexes are created by sqlite to enforce
|
||||
// different kinds of special constraints.
|
||||
// They do not have any SQL create statement as they are
|
||||
// created automatically by the constraints on the table.
|
||||
// They can not be re-created and need to be skipped.
|
||||
break;
|
||||
}
|
||||
createAffected.add(sql);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -94,6 +94,15 @@ class MockTransactionExecutor extends MockExecutor
|
|||
when(send()).thenAnswer((_) => Future.value(null));
|
||||
when(rollback()).thenAnswer((_) => Future.value(null));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> send() {
|
||||
return _nsm(Invocation.method(#send, []), Future.value(null));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> rollback() =>
|
||||
_nsm(Invocation.method(#rollback, []), Future.value(null));
|
||||
}
|
||||
|
||||
class MockStreamQueries extends Mock implements StreamQueryStore {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
//@dart=2.9
|
||||
import 'dart:async';
|
||||
|
||||
@TestOn('!browser') // todo: Figure out why this doesn't run in js
|
||||
|
@ -27,9 +26,9 @@ import 'data/tables/todos.dart';
|
|||
import 'data/utils/mocks.dart';
|
||||
|
||||
void main() {
|
||||
TodoDb db;
|
||||
MockExecutor executor;
|
||||
MockStreamQueries streamQueries;
|
||||
late TodoDb db;
|
||||
late MockExecutor executor;
|
||||
late MockStreamQueries streamQueries;
|
||||
|
||||
setUp(() {
|
||||
executor = MockExecutor();
|
||||
|
@ -43,7 +42,7 @@ void main() {
|
|||
// create a database without mocked stream queries
|
||||
db = TodoDb(MockExecutor());
|
||||
|
||||
Stream<int> stream;
|
||||
late Stream<int?> stream;
|
||||
|
||||
final didSetUpStream = Completer<void>();
|
||||
final makeUpdate = Completer<void>();
|
||||
|
@ -92,7 +91,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('stream queries terminate on exceptional transaction', () async {
|
||||
Stream stream;
|
||||
late Stream stream;
|
||||
|
||||
try {
|
||||
await db.transaction(() async {
|
||||
|
|
Loading…
Reference in New Issue