Skip to content

Commit

Permalink
Add simple test for SessionlessSyncConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsenko committed Jun 8, 2022
1 parent feb9a38 commit 54e82ba
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/configuration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import 'dart:io';
import 'dart:math';
import 'package:test/test.dart' hide test, throws;
import 'package:path/path.dart' as path_;
import '../lib/realm.dart';
import 'test.dart';

Expand Down Expand Up @@ -414,4 +415,26 @@ Future<void> main([List<String>? args]) async {

expect(config.path, 'my-custom-path.realm');
});

baasTest('Configuration.sessionlessSync', (appConfig) async {
final app = App(appConfig);
final user = await app.logIn(Credentials.emailPassword(testUsername, testPassword));

final dir = await Directory.systemTemp.createTemp();
final path = path_.join(dir.path, 'test.realm');

final schema = [Task.schema];
final flexibleSyncConfig = Configuration.flexibleSync(user, schema, path: path);
final realm = Realm(flexibleSyncConfig);
final oid = ObjectId();
realm.subscriptions.update((mutableSubscriptions) {
mutableSubscriptions.add(realm.query<Task>(r'_id == $0', [oid]));
});
realm.write(() => realm.add(Task(oid)));
realm.close();

final sessionlessSyncConfig = Configuration.sessionlessSync(schema, path: path);
final sessionlessRealm = Realm(sessionlessSyncConfig);
expect(sessionlessRealm.find<Task>(oid), isNotNull);
});
}

0 comments on commit 54e82ba

Please sign in to comment.