mirror of
https://github.com/immich-app/isar.git
synced 2026-09-30 13:23:02 +08:00
Fix tests
This commit is contained in:
@@ -6,7 +6,7 @@ homepage: https://isar.dev
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.0 <3.0.0"
|
||||
flutter: ">=2.0.0"
|
||||
flutter: ">=3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:exported="true">
|
||||
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||
the Android process has started. This theme is visible to the user
|
||||
while the Flutter UI initializes. After that, this theme continues
|
||||
|
||||
@@ -6,7 +6,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||
classpath 'com.android.tools.build:gradle:7.1.3'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'all_tests.dart' as tests;
|
||||
import 'test/util/common.dart';
|
||||
|
||||
void main() async {
|
||||
@@ -38,6 +39,6 @@ void executeTests(Completer<List<String>> completer) {
|
||||
completer.complete(result);
|
||||
});
|
||||
|
||||
//tests.main();
|
||||
tests.main();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,9 +120,7 @@ void main() {
|
||||
]);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('EmptyConstructorModel', () async {
|
||||
final obj1 = EmptyConstructorModel()..name = 'obj1';
|
||||
|
||||
@@ -111,6 +111,8 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('Query by dateTime', () async {
|
||||
await qEqualSet(
|
||||
isar.dateTimeModels
|
||||
|
||||
@@ -42,9 +42,7 @@ void main() {
|
||||
users = isar.userModels;
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('get() / put() without id', () async {
|
||||
final message1 = Message()
|
||||
|
||||
@@ -60,9 +60,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.equalTo() / .notEqualTo()', () async {
|
||||
// where clauses
|
||||
@@ -131,9 +129,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.anyEqualTo() / .anyNotEqualTo()', () async {
|
||||
// where clauses
|
||||
@@ -185,9 +181,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.equalTo() / .notEqualTo()', () async {
|
||||
// where clauses
|
||||
|
||||
@@ -80,9 +80,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.equalTo()', () async {
|
||||
// where clause
|
||||
|
||||
@@ -69,9 +69,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.greaterThan()', () async {
|
||||
// where clauses
|
||||
@@ -166,9 +164,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.anyGreaterThan() / .anyLessThan()', () async {
|
||||
// where clauses
|
||||
|
||||
@@ -48,9 +48,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.equalTo()', () async {
|
||||
// where clause
|
||||
|
||||
@@ -63,9 +63,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.equalTo()', () async {
|
||||
// where clause
|
||||
|
||||
@@ -79,9 +79,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('Single self link', () async {
|
||||
/*print(objA1.id);
|
||||
|
||||
@@ -70,9 +70,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('equalTo()', () async {
|
||||
await qEqual(
|
||||
|
||||
@@ -57,9 +57,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('sorted by value1 value2', () async {
|
||||
await qEqual(
|
||||
|
||||
@@ -84,9 +84,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.anyValue1Value2Value3', () async {
|
||||
await qEqual(
|
||||
|
||||
@@ -72,6 +72,8 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('getBy value1 sorted by value2', () async {
|
||||
await qEqual(
|
||||
col.where().value1EqualToAnyValue2('a').findAll(),
|
||||
|
||||
@@ -53,9 +53,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('getBy', () async {
|
||||
expect(await col.getByGuid(obj1.guid), obj1);
|
||||
|
||||
@@ -18,9 +18,7 @@ void main() {
|
||||
col = isar.userModels;
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
List<Map<String, dynamic>> generateJson(int count) {
|
||||
final json = <Map<String, dynamic>>[];
|
||||
|
||||
@@ -36,9 +36,7 @@ void main() {
|
||||
isar = await openTempIsar([NameModelSchema]);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('json', () async {
|
||||
await isar.tWriteTxn(
|
||||
|
||||
@@ -18,10 +18,12 @@ void main() {
|
||||
final isar1 = await openTempIsar([UserModelSchema]);
|
||||
final listenedIsar1 = await listener.next;
|
||||
expect(isar1, listenedIsar1);
|
||||
await isar1.close();
|
||||
|
||||
final isar2 = await openTempIsar([UserModelSchema]);
|
||||
final listenerIsar2 = await listener.next;
|
||||
expect(isar2, listenerIsar2);
|
||||
await isar2.close();
|
||||
|
||||
Isar.removeOpenListener(openListener);
|
||||
await listener.done();
|
||||
|
||||
@@ -5,23 +5,21 @@ import '../mutli_type_model.dart';
|
||||
import '../util/common.dart';
|
||||
import '../util/sync_async_helper.dart';
|
||||
|
||||
late Isar _isar;
|
||||
|
||||
IsarCollection<MultiTypeModel> get col => _isar.multiTypeModels;
|
||||
|
||||
void main() {
|
||||
group('Aggregation', () {
|
||||
late Isar isar;
|
||||
late IsarCollection<MultiTypeModel> col;
|
||||
|
||||
setUp(() async {
|
||||
_isar = await openTempIsar([MultiTypeModelSchema]);
|
||||
isar = await openTempIsar([MultiTypeModelSchema]);
|
||||
col = isar.multiTypeModels;
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await _isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
group('int', () {
|
||||
setUp(() async {
|
||||
await _isar.writeTxn(
|
||||
await isar.writeTxn(
|
||||
() => col.putAll([
|
||||
MultiTypeModel()..intValue = -5,
|
||||
MultiTypeModel()..intValue = 0,
|
||||
@@ -161,7 +159,7 @@ void main() {
|
||||
|
||||
group('float', () {
|
||||
setUp(() async {
|
||||
await _isar.writeTxn(
|
||||
await isar.writeTxn(
|
||||
() => col.putAll([
|
||||
MultiTypeModel()..floatValue = -5.0,
|
||||
MultiTypeModel()..floatValue = 0.0,
|
||||
@@ -301,7 +299,7 @@ void main() {
|
||||
|
||||
group('long', () {
|
||||
setUp(() async {
|
||||
await _isar.writeTxn(
|
||||
await isar.writeTxn(
|
||||
() => col.putAll([
|
||||
MultiTypeModel()..longValue = -5,
|
||||
MultiTypeModel()..longValue = 0,
|
||||
@@ -441,7 +439,7 @@ void main() {
|
||||
|
||||
group('double', () {
|
||||
setUp(() async {
|
||||
await _isar.writeTxn(
|
||||
await isar.writeTxn(
|
||||
() => col.putAll([
|
||||
MultiTypeModel()..doubleValue = -5.0,
|
||||
MultiTypeModel()..doubleValue = 0.0,
|
||||
@@ -584,7 +582,7 @@ void main() {
|
||||
DateTime.fromMillisecondsSinceEpoch(milliseconds);
|
||||
|
||||
setUp(() async {
|
||||
await _isar.writeTxn(
|
||||
await isar.writeTxn(
|
||||
() => col.putAll([
|
||||
MultiTypeModel()..dateTimeValue = date(-5),
|
||||
MultiTypeModel()..dateTimeValue = date(0),
|
||||
|
||||
@@ -31,7 +31,7 @@ void main() {
|
||||
late Model model2;
|
||||
late Model model3;
|
||||
|
||||
Future<void> setupModels() async {
|
||||
setUp(() async {
|
||||
model0 = Model(0, 0);
|
||||
model1 = Model(1, 1);
|
||||
model2 = Model(2, 2);
|
||||
@@ -40,13 +40,11 @@ void main() {
|
||||
await isar.writeTxn(() {
|
||||
return isar.models.putAll([model0, model1, model2, model3]);
|
||||
});
|
||||
}
|
||||
|
||||
group('where anyOf', () {
|
||||
setUp(setupModels);
|
||||
});
|
||||
|
||||
tearDown(() => isar.close());
|
||||
|
||||
group('where anyOf', () {
|
||||
isarTest('zero elements', () async {
|
||||
final one = isar.models.where().anyOf(
|
||||
<int>[],
|
||||
@@ -89,10 +87,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('filter anyOf', () {
|
||||
setUp(setupModels);
|
||||
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('zero elements', () async {
|
||||
final one = isar.models.filter().anyOf(
|
||||
<int>[],
|
||||
@@ -135,10 +129,6 @@ void main() {
|
||||
});
|
||||
|
||||
group('filter allOf', () {
|
||||
setUp(setupModels);
|
||||
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('zero elements', () async {
|
||||
final one = isar.models.filter().allOf(
|
||||
<int>[],
|
||||
|
||||
@@ -25,9 +25,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('Simple or', () async {
|
||||
await qEqualSet(
|
||||
|
||||
@@ -27,9 +27,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('0 offset', () async {
|
||||
final result = col.where().offset(0).tFindAll();
|
||||
|
||||
@@ -15,9 +15,7 @@ void main() {
|
||||
isar = await openTempIsar([MultiTypeModelSchema]);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('id property', () async {
|
||||
await isar.tWriteTxn(
|
||||
|
||||
@@ -26,9 +26,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.sortBy()', () async {
|
||||
await qEqual(
|
||||
|
||||
@@ -42,9 +42,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
isarTest('.any()', () async {
|
||||
await qEqual(
|
||||
|
||||
@@ -41,9 +41,7 @@ void main() {
|
||||
obj3 = Value(3, 'Test');
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await isar.close();
|
||||
});
|
||||
tearDown(() => isar.close());
|
||||
|
||||
group('Collection', () {
|
||||
isarTest('.put()', () async {
|
||||
|
||||
Reference in New Issue
Block a user