Skip to content

Commit

Permalink
Fix some new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Apr 7, 2022
1 parent fdb369e commit a9009fd
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions test/realm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -580,31 +580,27 @@ Future<void> main([List<String>? args]) async {

test('Realm write inside another write throws', () {
final config = Configuration([Car.schema]);
final realm = Realm(config);
final realm = getRealm(config);
realm.write(() {
// Second write inside the first one fails but the error is caught
expect(() => realm.write(() {}), throws<RealmException>('The Realm is already in a write transaction'));
});

realm.close();
});

test('Realm isInTransaction returns true inside transaction', () {
final config = Configuration([Car.schema]);
final realm = Realm(config);
final realm = getRealm(config);
expect(realm.isInTransaction, false);
realm.write(() {
expect(realm.isInTransaction, true);
});

expect(realm.isInTransaction, false);

realm.close();
});

test('Realm write with error rolls back', () {
final config = Configuration([Car.schema]);
final realm = Realm(config);
final realm = getRealm(config);
expect(realm.isInTransaction, false);

expect(() {
Expand All @@ -615,7 +611,5 @@ Future<void> main([List<String>? args]) async {

// We should not be in transaction here
expect(realm.isInTransaction, false);

realm.close();
});
}

0 comments on commit a9009fd

Please sign in to comment.