Skip to content

Commit

Permalink
Drop new async callback tests again
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsenko committed May 30, 2024
1 parent 8e401c3 commit f4dd7f8
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions packages/realm_dart/test/realm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1205,75 +1205,6 @@ void main() {
await expectLater(realm.writeAsync(() async {}), throwsA(isA<AssertionError>()));
});

test('Realm.writeAsync with async callback', () async {
final realm = getRealm(Configuration.local([Person.schema]));

await realm.writeAsync(() async {
await Future<void>.delayed(Duration(milliseconds: 10));
realm.add(Person('John'));
});

expect(realm.all<Person>().length, 1);
expect(realm.isInTransaction, false);
}, skip: 'async callbacks are explicitly prohibited for now');

test('Realm.writeAsync concurrent transaction are queued', () async {
final realm = getRealm(Configuration.local([Person.schema]));
final john = Person('John');
final jane = Person('Jane');

await expectLater(
Future.wait([
realm.writeAsync(() async {
await Future<void>.delayed(Duration(milliseconds: 100));
return realm.add(john);
}),
realm.writeAsync(() async => realm.add(jane)),
]),
completion([john, jane]),
);
expect(realm.all<Person>().length, 2); // both transactions are committed
expect(realm.all<Person>(), [john, jane]); // and order is preserved
}, skip: 'async callbacks are explicitly prohibited for now');

test('Realm.writeAsync concurrent transactions fails independently', () async {
final realm = getRealm(Configuration.local([Person.schema]));
final john = Person('John');
final jane = Person('Jane');

await expectLater(
Future.wait(
eagerError: false,
[
realm.writeAsync(() async {
realm.add(john);
throw Exception(); // fail transaction and roll back
}),
realm.writeAsync(() async => realm.add(jane)),
],
),
throwsException,
);
expect(realm.all<Person>().length, 1); // only first transaction is rolled back
expect(realm.all<Person>(), [jane]); // second transaction is committed
}, skip: 'async callbacks are explicitly prohibited for now');

test('Realm.writeAsync is not re-entrant', () async {
final realm = getRealm(Configuration.local([Person.schema]));
final john = Person('John');

final ct = TimeoutCancellationToken(const Duration(milliseconds: 100));
await expectLater(
realm.writeAsync(() async {
realm.add(john);
// this would deadlock, if not for the timeout
await realm.writeAsync(() {}, ct);
}),
throwsA(isA<TimeoutException>()),
);
expect(realm.all<Person>().length, 0); // everything is rolled back
}, skip: 'async callbacks are explicitly prohibited for now');

test('Realm.write with async callback', () {
final realm = getRealm(Configuration.local([Person.schema]));
expect(() => realm.write(() async {}), throwsA(isA<AssertionError>()));
Expand Down

0 comments on commit f4dd7f8

Please sign in to comment.