Skip to content

Commit

Permalink
moving from windows to mac for better testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MongoCaleb committed Aug 1, 2024
1 parent d1bf9fd commit 497a581
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 59 deletions.
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 = "[email protected]";
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
2 changes: 0 additions & 2 deletions examples/dart/test/compact_realm_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:test/test.dart';
import '../bin/models/car.dart';
import 'package:realm_dart/realm.dart';
import 'package:path/path.dart' as path;
import 'dart:io';
import './utils.dart';

void main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/dart/test/data_ingest.test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ void main() {
// Because the Flutter/Dart SDK doesn't have a mongoClient yet,
// we can't test that asymmetric objects exist in the backend.
group('Create asymmetric abject and use Data Ingest', () {
const APP_ID = "flutter-flexible-luccm";
final appConfig = AppConfiguration(APP_ID);
const appId = "flutter-flexible-luccm";
final appConfig = AppConfiguration(appId);
final app = App(appConfig);

test("Create asymmetric object locally", () async {
Expand Down
2 changes: 0 additions & 2 deletions examples/dart/test/delete_realm_test.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'package:test/test.dart';
import '../bin/models/car.dart';
import 'package:realm_dart/realm.dart';
import 'package:path/path.dart' as path;
import 'dart:io';
import './utils.dart';
import 'dart:io';

void main() {
test('Delete a Realm', () async {
Expand Down
4 changes: 2 additions & 2 deletions examples/dart/test/freeze_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ void main() {
// Update data in the non-frozen realm
final newLastName = "Foo";
realm.write(() {
people.forEach((Person person) {
for (var person in people) {
person.lastName = newLastName;
});
}
});

// Data changes not in the frozen snapshot
Expand Down
1 change: 0 additions & 1 deletion examples/dart/test/functions_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'dart:convert';
import 'package:realm_dart/realm.dart';
import 'package:test/test.dart';

Expand Down
8 changes: 2 additions & 6 deletions examples/dart/test/migrations_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ void main() {
// That person must have been deleted, so nothing to do.
continue;
}
newPerson.fullName = oldPerson.dynamic.get<String>("firstName") +
" " +
oldPerson.dynamic.get<String>("lastName");
newPerson.fullName = "${oldPerson.dynamic.get<String>("firstName")} ${oldPerson.dynamic.get<String>("lastName")}";
final oldId = oldPerson.dynamic.get<ObjectId>("id");
newPerson.id = oldId.toString();
}
Expand Down Expand Up @@ -110,9 +108,7 @@ void main() {
}
// Use dynamic API to get properties from old schema and use in the
// new schema
newPerson.fullName = oldPerson.dynamic.get<String>("firstName") +
" " +
oldPerson.dynamic.get<String>("lastName");
newPerson.fullName = "${oldPerson.dynamic.get<String>("firstName")} ${oldPerson.dynamic.get<String>("lastName")}";
// convert `id` from ObjectId to String
final oldId = oldPerson.dynamic.get<ObjectId>("id");
newPerson.id = oldId.toString();
Expand Down
31 changes: 12 additions & 19 deletions examples/dart/test/open_flexible_sync_realm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class _Car {

void main() {
group('Open Flexible Sync Realm', () {
const APP_ID = "flutter-flexible-luccm";
final appConfig = AppConfiguration(APP_ID);
const appId = "flutter-flexible-luccm";
final appConfig = AppConfiguration(appId);
final app = App(appConfig);
test("Open Flexible Sync Realm", () async {
final credentials = Credentials.anonymous();
Expand Down Expand Up @@ -71,31 +71,24 @@ void main() {
test('Track download progress', () async {
final credentials = Credentials.anonymous();
final currentUser = await app.logIn(credentials);
late int transferred;
late int transferable;
late double progress = -1;
final config = Configuration.flexibleSync(currentUser, [Tricycle.schema]);
// :snippet-start: async-open-track-progress
final realm =
await Realm.open(config, onProgressCallback: (syncProgress) {
if (syncProgress.transferableBytes == syncProgress.transferredBytes) {
print('All bytes transferred!');
// :remove-start:
transferred = syncProgress.transferredBytes;
transferable = syncProgress.transferableBytes;
// :remove-end:
}
final realm = await Realm.open(config, onProgressCallback: (syncProgress) {
progress = syncProgress.progressEstimate;
// Percent complete == progress * 100
if (syncProgress.progressEstimate == 1.0) {
//transfer is complete
}
});
// :snippet-end:
expect(realm.isClosed, false);
expect(transferred, transferable);
expect(transferred, greaterThanOrEqualTo(0));
expect(progress, greaterThanOrEqualTo(0));
cleanUpRealm(realm, app);
});
test('Cancel download in progress', () async {
final credentials = Credentials.anonymous();
final currentUser = await app.logIn(credentials);
late int transferred;
late int transferable;
final config = Configuration.flexibleSync(currentUser, [Tricycle.schema]);
// :snippet-start: async-open-cancel
final token = CancellationToken();
Expand Down Expand Up @@ -132,7 +125,7 @@ void main() {
final config = Configuration.flexibleSync(currentUser, [Car.schema],
syncErrorHandler: (SyncError error) {
handlerCalled = true; // :remove:
print("Error message" + error.message.toString());
print("Error message${error.message}");
});

final realm = Realm(config);
Expand Down Expand Up @@ -176,7 +169,7 @@ void main() {
testCompensatingWriteError = compensatingWriteError; // :remove:
final writeReason = compensatingWriteError.compensatingWrites!.first;

print("Error message: " + writeReason.reason);
print("Error message: ${writeReason.reason}");
// ... handle compensating write error as needed.
}

Expand Down
4 changes: 4 additions & 0 deletions examples/dart/test/pet.realm.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/dart/test/quick_start_sync_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class _Todo {

void main() async {
test('Add query to subscription set', () async {
const YOUR_APP_ID_HERE = 'flutter-flexible-luccm'; // :remove:
const yourAppIdHere = 'flutter-flexible-luccm'; // :remove:
// Add your App Services App ID
const APP_ID = YOUR_APP_ID_HERE;
const appId = yourAppIdHere;
// :snippet-start: init-app
final app = App(AppConfiguration(APP_ID));
final app = App(AppConfiguration(appId));
// :snippet-end:
// :snippet-start: log-in
final loggedInUser = await app.logIn(Credentials.anonymous());
Expand Down
1 change: 0 additions & 1 deletion examples/dart/test/quick_start_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:test/test.dart';
import '../bin/models/car.dart';
import 'package:realm_dart/realm.dart';

import 'utils.dart';

void main() {
group('CRUD Operations', () {
Expand Down
9 changes: 9 additions & 0 deletions examples/dart/test/serialization_test.realm.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/dart/test/sync_multiple_processes_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @Skip('hmm')
import 'dart:io';

import 'package:test/test.dart';
import 'package:realm_dart/realm.dart';
Expand Down
5 changes: 2 additions & 3 deletions examples/dart/test/utils.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 'dart:math';
Expand All @@ -17,8 +16,8 @@ Future<void> cleanUpRealm(Realm realm, [App? app]) async {

final random = Random();
String generateRandomString(int len) {
const _chars = 'abcdefghjklmnopqrstuvwxuz';
return List.generate(len, (index) => _chars[random.nextInt(_chars.length)])
const chars = 'abcdefghjklmnopqrstuvwxuz';
return List.generate(len, (index) => chars[random.nextInt(chars.length)])
.join();
}

Expand Down

0 comments on commit 497a581

Please sign in to comment.