Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates Dart tests to use new notification API #3354

Merged
merged 12 commits into from
Aug 9, 2024
7 changes: 6 additions & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ jobs:
run: dart run realm_dart install

- name: Run Realm SDK tests
run: ./scripts/test.sh
run: |
if ./scripts/test.sh --concurrency=1 2>&1 | grep "Some tests failed."
then
exit 1
fi

8 changes: 4 additions & 4 deletions examples/dart/bin/myapp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ void main(List<String> arguments) async {
realm.add(Car(ObjectId(), "Audi", model: 'A8'));
realm.add(Car(ObjectId(), "Mercedes", model: 'G Wagon'));
});
print("Bundled realm location: " + realm.config.path);
print("Bundled realm location: ${realm.config.path}");
realm.close();
// :snippet-end:
Future<void> createSyncedBundle() async {
final APP_ID = 'flutter-flexible-luccm';
final appId = 'flutter-flexible-luccm';
// :snippet-start: create-synced-bundle
print("Bundling synced realm");

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

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

print("Bundled realm location: " + bundledConfig.path);
print("Bundled realm location: ${bundledConfig.path}");
realm.close();
// :snippet-end:
}
Expand Down
80 changes: 40 additions & 40 deletions examples/dart/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
source: hosted
version: "1.18.0"
version: "1.19.0"
convert:
dependency: transitive
description:
Expand All @@ -178,10 +178,10 @@ packages:
dependency: transitive
description:
name: coverage
sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e"
sha256: "576aaab8b1abdd452e0f656c3e73da9ead9d7880e15bdc494189d9c1a1baf0db"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
version: "1.9.0"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -226,18 +226,18 @@ packages:
dependency: transitive
description:
name: ejson
sha256: f336c6fb6c5c97db8ae59ba8ed207f542241f1db39cf2ef03776d308de3432ff
sha256: "42bdc6f57444e8c9cbf2c8dc8044424c27890a1d8cf64953b95f02d289afd88b"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "0.3.1"
ejson_annotation:
dependency: transitive
description:
name: ejson_annotation
sha256: b265eea722ee340d77d1c36a55a1f963d517a0dabb569b0775664c319a4e3ebf
sha256: "7053cff1b6acf375b8e76270d576915fe434701f1f25b5751c8f9e1e73e50bcf"
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "0.3.1"
faker:
dependency: "direct main"
description:
Expand Down Expand Up @@ -290,18 +290,18 @@ packages:
dependency: transitive
description:
name: graphs
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
sha256: "741bbf84165310a68ff28fe9e727332eef1407342fca52759cb21ad8177bb8d0"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
http:
dependency: transitive
description:
name: http
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.2.2"
http_multi_server:
dependency: transitive
description:
Expand All @@ -314,10 +314,10 @@ packages:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
sha256: "40f592dd352890c3b60fec1b68e786cefb9603e05ff303dbc4dda49b304ecdf4"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
version: "4.1.0"
intl:
dependency: transitive
description:
Expand Down Expand Up @@ -474,42 +474,42 @@ packages:
dependency: transitive
description:
name: realm_common
sha256: "6db42e97d88a2866521467faa409aca3b92605071e1eb56c9afee78518ed0721"
sha256: "73919ec7a92cca6d6889cbf2688cca53e92779a115f5bba5bc69eb341c29581f"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.3.0"
realm_dart:
dependency: "direct main"
description:
name: realm_dart
sha256: "1b5783b5ef88f7b7e34fe67ab7641ba1d0939052b5ad2c9391b0b2a9171a2a49"
sha256: "5ba69ba9a7533beedb23b64ea16291728c1cff2143f699f82bcfae958fcec50b"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.3.0"
realm_generator:
dependency: transitive
description:
name: realm_generator
sha256: "99e056fb6dab76679e9de8928bc7b87e95f162e4cbc569dca09727066d96d63a"
sha256: ab1743027815a543faf348b12361662a2bf8ec7b9bcc0d9847276db70430c79e
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.3.0"
sane_uuid:
dependency: transitive
description:
name: sane_uuid
sha256: "5e83f796a7d19d38d3ba3a940642998fdd8c4a4049be135ed25404e37f76a18c"
sha256: "5b3fd581f51d01aef0526344c175e198d04ff701249c1a75186429dbb4367265"
url: "https://pub.dev"
source: hosted
version: "1.0.0-alpha.5"
version: "1.1.0"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12
url: "https://pub.dev"
source: hosted
version: "1.4.1"
version: "1.4.2"
shelf_packages_handler:
dependency: transitive
description:
Expand Down Expand Up @@ -594,10 +594,10 @@ packages:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.3.0"
tar:
dependency: transitive
description:
Expand All @@ -618,26 +618,26 @@ packages:
dependency: "direct main"
description:
name: test
sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e"
sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f"
url: "https://pub.dev"
source: hosted
version: "1.25.7"
version: "1.25.8"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
version: "0.7.3"
test_core:
dependency: transitive
description:
name: test_core
sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696"
sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d"
url: "https://pub.dev"
source: hosted
version: "0.6.4"
version: "0.6.5"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -666,10 +666,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "360c4271613beb44db559547d02f8b0dc044741d0eeb9aa6ccdb47e8ec54c63a"
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
url: "https://pub.dev"
source: hosted
version: "14.2.3"
version: "14.2.4"
watcher:
dependency: transitive
description:
Expand All @@ -682,26 +682,26 @@ packages:
dependency: transitive
description:
name: web
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "1.0.0"
web_socket:
dependency: transitive
description:
name: web_socket
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
sha256: "3c12d96c0c9a4eec095246debcea7b86c0324f22df69893d538fcc6f1b8cce83"
url: "https://pub.dev"
source: hosted
version: "0.1.5"
version: "0.1.6"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
sha256: "9f187088ed104edd8662ca07af4b124465893caf063ba29758f97af57e61da8f"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
version: "3.0.1"
webkit_inspection_protocol:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion examples/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
dart_jsonwebtoken: ^2.4.2
faker: ^2.0.0
test: ^1.20.1
realm_dart: ^3.0.0
realm_dart: ^3.3.0

dev_dependencies:
lints: ^4.0.0
Expand Down
4 changes: 2 additions & 2 deletions examples/dart/test/access_token_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import 'package:realm_dart/realm.dart';
import 'dart:convert';

void main() {
const APP_ID = "example-testers-kvjdy";
const appId = "example-testers-kvjdy";
group('Access tokens - ', () {
late App app;
setUp(() async {
final appConfig = AppConfiguration(APP_ID);
final appConfig = AppConfiguration(appId);
app = App(appConfig);
final authProvider = EmailPasswordAuthProvider(app);
final email = "lisa@example.com";
Expand Down
4 changes: 2 additions & 2 deletions examples/dart/test/add_sync_to_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class _Car {
}

void main() {
const APP_ID = "flutter-flexible-luccm";
const appId = "flutter-flexible-luccm";

test("Add Sync to App", () async {
// :snippet-start: connect-to-app
final app = App(AppConfiguration(APP_ID));
final app = App(AppConfiguration(appId));
// :snippet-end:
// :snippet-start: log-in
final user = await app.logIn(Credentials.anonymous());
Expand Down
19 changes: 9 additions & 10 deletions examples/dart/test/app_services_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@ import "dart:convert";
import "dart:isolate";

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

group('App Services client - ', () {
test('Access App client', () {
// :snippet-start: access-app-client
final appConfig = AppConfiguration(APP_ID);
final appConfig = AppConfiguration(appId);
final app = App(appConfig);
//:snippet-end:
expect(app, isNotNull);
expect(app.id, APP_ID);
expect(app.id, appId);
});
test('App client advanced configuration', () {
// :snippet-start: app-client-advanced-configuration
final appConfig = AppConfiguration(APP_ID,
final appConfig = AppConfiguration(appId,
defaultRequestTimeout: const Duration(seconds: 120)
// ... see reference docs for all available configuration options
);
//:snippet-end:
final app = App(appConfig);
expect(app, isNotNull);
expect(app.id, APP_ID);
expect(app.id, appId);
expect(appConfig.defaultRequestTimeout, Duration(seconds: 120));
});

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

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

var app = App(appConfig);
Expand All @@ -73,9 +73,8 @@ void main() {
// :snippet-start: access-app-by-id
// Create an App instance once on main isolate,
// ideally as soon as the app starts
final appConfig = AppConfiguration(APP_ID);
final appConfig = AppConfiguration(appId);
final app = App(appConfig);
final appId = app.id;
final receivePort = ReceivePort();
// :remove-start:
expect(app, isNotNull);
Expand Down
4 changes: 2 additions & 2 deletions examples/dart/test/authenticate_users_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,11 @@ void main() {
// :snippet-end:
});
test('Remove a user from the device', () async {
late var user;
late User? user;
if (app.currentUser != null) {
user = app.currentUser;
// :snippet-start: remove-user
await app.removeUser(user);
await app.removeUser(user!);
// :snippet-end:
}
});
Expand Down
1 change: 0 additions & 1 deletion examples/dart/test/client_reset_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dart:io';

import 'package:realm_dart/realm.dart';
import 'package:test/test.dart';
Expand Down
Loading
Loading