Skip to content

Commit f003a01

Browse files
authored
Updates Dart tests to use new notification API (#3354)
## Pull Request Info - SDK Docs Consolidation Jira ticket: hhttps://jira.mongodb.org/browse/DOCSP-40843 ### Staging Links <!-- start insert-links --> <li><a href=https://deploy-preview-3354--docs-realm.netlify.app/sdk/flutter/sync/manage-sync-session>sdk/flutter/sync/manage-sync-session</a></li><li><a href=https://deploy-preview-3354--docs-realm.netlify.app/sdk/flutter/sync/open-synced-realm>sdk/flutter/sync/open-synced-realm</a></li> <!-- end insert-links --> ### Release Notes - **Dart/Flutter SDK** - Add new unit test to show progressEstimate SDK addition. - Run `dart fix` to clean up all code examples and then re-bluehawk them all.
1 parent 3c909ae commit f003a01

40 files changed

+191
-147
lines changed

.github/workflows/dart.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ jobs:
2828
run: dart run realm_dart install
2929

3030
- name: Run Realm SDK tests
31-
run: ./scripts/test.sh
31+
run: |
32+
if ./scripts/test.sh --concurrency=1 2>&1 | grep "Some tests failed."
33+
then
34+
exit 1
35+
fi
36+

examples/dart/bin/myapp.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ void main(List<String> arguments) async {
1212
realm.add(Car(ObjectId(), "Audi", model: 'A8'));
1313
realm.add(Car(ObjectId(), "Mercedes", model: 'G Wagon'));
1414
});
15-
print("Bundled realm location: " + realm.config.path);
15+
print("Bundled realm location: ${realm.config.path}");
1616
realm.close();
1717
// :snippet-end:
1818
Future<void> createSyncedBundle() async {
19-
final APP_ID = 'flutter-flexible-luccm';
19+
final appId = 'flutter-flexible-luccm';
2020
// :snippet-start: create-synced-bundle
2121
print("Bundling synced realm");
2222

2323
// You must connect to the Device Sync server with an authenticated
2424
// user to work with the synced realm.
25-
final app = App(AppConfiguration(APP_ID));
25+
final app = App(AppConfiguration(appId));
2626
// Check if current user exists and log anonymous user if not.
2727
final user = app.currentUser ?? await app.logIn(Credentials.anonymous());
2828

@@ -54,7 +54,7 @@ void main(List<String> arguments) async {
5454
path: 'sync_bundle.realm');
5555
realm.writeCopy(bundledConfig);
5656

57-
print("Bundled realm location: " + bundledConfig.path);
57+
print("Bundled realm location: ${bundledConfig.path}");
5858
realm.close();
5959
// :snippet-end:
6060
}

examples/dart/pubspec.lock

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ packages:
162162
dependency: transitive
163163
description:
164164
name: collection
165-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
165+
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
166166
url: "https://pub.dev"
167167
source: hosted
168-
version: "1.18.0"
168+
version: "1.19.0"
169169
convert:
170170
dependency: transitive
171171
description:
@@ -178,10 +178,10 @@ packages:
178178
dependency: transitive
179179
description:
180180
name: coverage
181-
sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e"
181+
sha256: "576aaab8b1abdd452e0f656c3e73da9ead9d7880e15bdc494189d9c1a1baf0db"
182182
url: "https://pub.dev"
183183
source: hosted
184-
version: "1.8.0"
184+
version: "1.9.0"
185185
crypto:
186186
dependency: transitive
187187
description:
@@ -226,18 +226,18 @@ packages:
226226
dependency: transitive
227227
description:
228228
name: ejson
229-
sha256: f336c6fb6c5c97db8ae59ba8ed207f542241f1db39cf2ef03776d308de3432ff
229+
sha256: "42bdc6f57444e8c9cbf2c8dc8044424c27890a1d8cf64953b95f02d289afd88b"
230230
url: "https://pub.dev"
231231
source: hosted
232-
version: "0.3.0"
232+
version: "0.3.1"
233233
ejson_annotation:
234234
dependency: transitive
235235
description:
236236
name: ejson_annotation
237-
sha256: b265eea722ee340d77d1c36a55a1f963d517a0dabb569b0775664c319a4e3ebf
237+
sha256: "7053cff1b6acf375b8e76270d576915fe434701f1f25b5751c8f9e1e73e50bcf"
238238
url: "https://pub.dev"
239239
source: hosted
240-
version: "0.3.0"
240+
version: "0.3.1"
241241
faker:
242242
dependency: "direct main"
243243
description:
@@ -290,18 +290,18 @@ packages:
290290
dependency: transitive
291291
description:
292292
name: graphs
293-
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
293+
sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0"
294294
url: "https://pub.dev"
295295
source: hosted
296-
version: "2.3.1"
296+
version: "2.3.2"
297297
http:
298298
dependency: transitive
299299
description:
300300
name: http
301-
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
301+
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
302302
url: "https://pub.dev"
303303
source: hosted
304-
version: "1.2.1"
304+
version: "1.2.2"
305305
http_multi_server:
306306
dependency: transitive
307307
description:
@@ -314,10 +314,10 @@ packages:
314314
dependency: transitive
315315
description:
316316
name: http_parser
317-
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
317+
sha256: "40f592dd352890c3b60fec1b68e786cefb9603e05ff303dbc4dda49b304ecdf4"
318318
url: "https://pub.dev"
319319
source: hosted
320-
version: "4.0.2"
320+
version: "4.1.0"
321321
intl:
322322
dependency: transitive
323323
description:
@@ -474,42 +474,42 @@ packages:
474474
dependency: transitive
475475
description:
476476
name: realm_common
477-
sha256: "6db42e97d88a2866521467faa409aca3b92605071e1eb56c9afee78518ed0721"
477+
sha256: "73919ec7a92cca6d6889cbf2688cca53e92779a115f5bba5bc69eb341c29581f"
478478
url: "https://pub.dev"
479479
source: hosted
480-
version: "3.0.0"
480+
version: "3.3.0"
481481
realm_dart:
482482
dependency: "direct main"
483483
description:
484484
name: realm_dart
485-
sha256: "1b5783b5ef88f7b7e34fe67ab7641ba1d0939052b5ad2c9391b0b2a9171a2a49"
485+
sha256: "5ba69ba9a7533beedb23b64ea16291728c1cff2143f699f82bcfae958fcec50b"
486486
url: "https://pub.dev"
487487
source: hosted
488-
version: "3.0.0"
488+
version: "3.3.0"
489489
realm_generator:
490490
dependency: transitive
491491
description:
492492
name: realm_generator
493-
sha256: "99e056fb6dab76679e9de8928bc7b87e95f162e4cbc569dca09727066d96d63a"
493+
sha256: ab1743027815a543faf348b12361662a2bf8ec7b9bcc0d9847276db70430c79e
494494
url: "https://pub.dev"
495495
source: hosted
496-
version: "3.0.0"
496+
version: "3.3.0"
497497
sane_uuid:
498498
dependency: transitive
499499
description:
500500
name: sane_uuid
501-
sha256: "5e83f796a7d19d38d3ba3a940642998fdd8c4a4049be135ed25404e37f76a18c"
501+
sha256: "5b3fd581f51d01aef0526344c175e198d04ff701249c1a75186429dbb4367265"
502502
url: "https://pub.dev"
503503
source: hosted
504-
version: "1.0.0-alpha.5"
504+
version: "1.1.0"
505505
shelf:
506506
dependency: transitive
507507
description:
508508
name: shelf
509-
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
509+
sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12
510510
url: "https://pub.dev"
511511
source: hosted
512-
version: "1.4.1"
512+
version: "1.4.2"
513513
shelf_packages_handler:
514514
dependency: transitive
515515
description:
@@ -594,10 +594,10 @@ packages:
594594
dependency: transitive
595595
description:
596596
name: string_scanner
597-
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
597+
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
598598
url: "https://pub.dev"
599599
source: hosted
600-
version: "1.2.0"
600+
version: "1.3.0"
601601
tar:
602602
dependency: transitive
603603
description:
@@ -618,26 +618,26 @@ packages:
618618
dependency: "direct main"
619619
description:
620620
name: test
621-
sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e"
621+
sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f"
622622
url: "https://pub.dev"
623623
source: hosted
624-
version: "1.25.7"
624+
version: "1.25.8"
625625
test_api:
626626
dependency: transitive
627627
description:
628628
name: test_api
629-
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
629+
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
630630
url: "https://pub.dev"
631631
source: hosted
632-
version: "0.7.2"
632+
version: "0.7.3"
633633
test_core:
634634
dependency: transitive
635635
description:
636636
name: test_core
637-
sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696"
637+
sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d"
638638
url: "https://pub.dev"
639639
source: hosted
640-
version: "0.6.4"
640+
version: "0.6.5"
641641
timing:
642642
dependency: transitive
643643
description:
@@ -666,10 +666,10 @@ packages:
666666
dependency: transitive
667667
description:
668668
name: vm_service
669-
sha256: "360c4271613beb44db559547d02f8b0dc044741d0eeb9aa6ccdb47e8ec54c63a"
669+
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
670670
url: "https://pub.dev"
671671
source: hosted
672-
version: "14.2.3"
672+
version: "14.2.4"
673673
watcher:
674674
dependency: transitive
675675
description:
@@ -682,26 +682,26 @@ packages:
682682
dependency: transitive
683683
description:
684684
name: web
685-
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
685+
sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
686686
url: "https://pub.dev"
687687
source: hosted
688-
version: "0.5.1"
688+
version: "1.0.0"
689689
web_socket:
690690
dependency: transitive
691691
description:
692692
name: web_socket
693-
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
693+
sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83"
694694
url: "https://pub.dev"
695695
source: hosted
696-
version: "0.1.5"
696+
version: "0.1.6"
697697
web_socket_channel:
698698
dependency: transitive
699699
description:
700700
name: web_socket_channel
701-
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
701+
sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f"
702702
url: "https://pub.dev"
703703
source: hosted
704-
version: "3.0.0"
704+
version: "3.0.1"
705705
webkit_inspection_protocol:
706706
dependency: transitive
707707
description:

examples/dart/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
dart_jsonwebtoken: ^2.4.2
1212
faker: ^2.0.0
1313
test: ^1.20.1
14-
realm_dart: ^3.0.0
14+
realm_dart: ^3.3.0
1515

1616
dev_dependencies:
1717
lints: ^4.0.0

examples/dart/test/access_token_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import 'package:realm_dart/realm.dart';
44
import 'dart:convert';
55

66
void main() {
7-
const APP_ID = "example-testers-kvjdy";
7+
const appId = "example-testers-kvjdy";
88
group('Access tokens - ', () {
99
late App app;
1010
setUp(() async {
11-
final appConfig = AppConfiguration(APP_ID);
11+
final appConfig = AppConfiguration(appId);
1212
app = App(appConfig);
1313
final authProvider = EmailPasswordAuthProvider(app);
1414
final email = "[email protected]";

examples/dart/test/add_sync_to_app.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class _Car {
1616
}
1717

1818
void main() {
19-
const APP_ID = "flutter-flexible-luccm";
19+
const appId = "flutter-flexible-luccm";
2020

2121
test("Add Sync to App", () async {
2222
// :snippet-start: connect-to-app
23-
final app = App(AppConfiguration(APP_ID));
23+
final app = App(AppConfiguration(appId));
2424
// :snippet-end:
2525
// :snippet-start: log-in
2626
final user = await app.logIn(Credentials.anonymous());

examples/dart/test/app_services_test.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,38 @@ import "dart:convert";
66
import "dart:isolate";
77

88
void main() {
9-
const APP_ID = "example-testers-kvjdy";
10-
const EDGE_SERVER_APP_ID = "sync-edge-server-cskhoow";
9+
const appId = "example-testers-kvjdy";
10+
const edgeServerAppId = "sync-edge-server-cskhoow";
1111
const baseUrl = 'http://localhost';
1212
const newBaseUrl = 'https://services.cloud.mongodb.com';
1313

1414
group('App Services client - ', () {
1515
test('Access App client', () {
1616
// :snippet-start: access-app-client
17-
final appConfig = AppConfiguration(APP_ID);
17+
final appConfig = AppConfiguration(appId);
1818
final app = App(appConfig);
1919
//:snippet-end:
2020
expect(app, isNotNull);
21-
expect(app.id, APP_ID);
21+
expect(app.id, appId);
2222
});
2323
test('App client advanced configuration', () {
2424
// :snippet-start: app-client-advanced-configuration
25-
final appConfig = AppConfiguration(APP_ID,
25+
final appConfig = AppConfiguration(appId,
2626
defaultRequestTimeout: const Duration(seconds: 120)
2727
// ... see reference docs for all available configuration options
2828
);
2929
//:snippet-end:
3030
final app = App(appConfig);
3131
expect(app, isNotNull);
32-
expect(app.id, APP_ID);
32+
expect(app.id, appId);
3333
expect(appConfig.defaultRequestTimeout, Duration(seconds: 120));
3434
});
3535

3636
test('Custom BaseUrl', () {
3737
// :snippet-start: custom-base-url
3838
// Specify a baseUrl to connect to a server other than the default
3939
final appConfig =
40-
AppConfiguration(APP_ID, baseUrl: Uri.parse('https://example.com'));
40+
AppConfiguration(appId, baseUrl: Uri.parse('https://example.com'));
4141

4242
var app = App(appConfig);
4343
// :snippet-end:
@@ -48,7 +48,7 @@ void main() {
4848
// :snippet-start: change-base-url
4949
// Specify a custom baseUrl to connect to.
5050
// In this case, an Edge Server instance running on the device.
51-
final appConfig = AppConfiguration(EDGE_SERVER_APP_ID,
51+
final appConfig = AppConfiguration(edgeServerAppId,
5252
baseUrl: Uri.parse('http://localhost:80'));
5353

5454
var app = App(appConfig);
@@ -73,9 +73,8 @@ void main() {
7373
// :snippet-start: access-app-by-id
7474
// Create an App instance once on main isolate,
7575
// ideally as soon as the app starts
76-
final appConfig = AppConfiguration(APP_ID);
76+
final appConfig = AppConfiguration(appId);
7777
final app = App(appConfig);
78-
final appId = app.id;
7978
final receivePort = ReceivePort();
8079
// :remove-start:
8180
expect(app, isNotNull);

examples/dart/test/authenticate_users_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ void main() {
335335
// :snippet-end:
336336
});
337337
test('Remove a user from the device', () async {
338-
late var user;
338+
late User? user;
339339
if (app.currentUser != null) {
340340
user = app.currentUser;
341341
// :snippet-start: remove-user
342-
await app.removeUser(user);
342+
await app.removeUser(user!);
343343
// :snippet-end:
344344
}
345345
});

examples/dart/test/client_reset_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'dart:io';
21

32
import 'package:realm_dart/realm.dart';
43
import 'package:test/test.dart';

0 commit comments

Comments
 (0)