mirror of
https://github.com/immich-app/drift.git
synced 2026-09-30 21:27:45 +08:00
Update integration tests for drift_sqflite
This commit is contained in:
@@ -26,6 +26,7 @@ apply plugin: 'kotlin-android'
|
|||||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
namespace 'com.example.drift_sqflite'
|
||||||
compileSdkVersion flutter.compileSdkVersion
|
compileSdkVersion flutter.compileSdkVersion
|
||||||
ndkVersion flutter.ndkVersion
|
ndkVersion flutter.ndkVersion
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
classpath 'com.android.tools.build:gradle:8.0.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,6 @@ subprojects {
|
|||||||
project.evaluationDependsOn(':app')
|
project.evaluationDependsOn(':app')
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
tasks.register("clean", Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:sqflite/sqflite.dart' show getDatabasesPath;
|
import 'package:sqflite/sqflite.dart' show DatabaseException, getDatabasesPath;
|
||||||
|
|
||||||
class SqfliteExecutor extends TestExecutor {
|
class SqfliteExecutor extends TestExecutor {
|
||||||
@override
|
@override
|
||||||
@@ -99,11 +99,19 @@ Future<void> main() async {
|
|||||||
await database.customStatement('CREATE TABLE y (foo INTEGER PRIMARY KEY '
|
await database.customStatement('CREATE TABLE y (foo INTEGER PRIMARY KEY '
|
||||||
'REFERENCES x (foo) DEFERRABLE INITIALLY DEFERRED);');
|
'REFERENCES x (foo) DEFERRABLE INITIALLY DEFERRED);');
|
||||||
|
|
||||||
|
// On Android, the failing commit of the transaction rolls it back implicitly,
|
||||||
|
// causing the drift's rollback recovery to fail. This is expected and not
|
||||||
|
// harmful since the end result (transaction not applied) is the same. On
|
||||||
|
// iOS, the transaction stays active despite the failing commit.
|
||||||
|
final expectedException = Platform.isAndroid
|
||||||
|
? isA<CouldNotRollBackException>()
|
||||||
|
: isA<DatabaseException>();
|
||||||
|
|
||||||
await expectLater(
|
await expectLater(
|
||||||
database.transaction(() async {
|
database.transaction(() async {
|
||||||
await database.customStatement('INSERT INTO y VALUES (2);');
|
await database.customStatement('INSERT INTO y VALUES (2);');
|
||||||
}),
|
}),
|
||||||
throwsA(isA<CouldNotRollBackException>()),
|
throwsA(expectedException),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user