Skip to content

Commit

Permalink
fixup! Tests: macOS now correctly throws unique violation exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
greenrobot-team committed Oct 16, 2023
1 parent 9cbd7af commit b9d173d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 7 additions & 0 deletions objectbox_test/test/basics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import 'package:objectbox/src/native/bindings/helpers.dart';
import 'package:objectbox/src/native/version.dart';
import 'package:test/test.dart';

import 'test_env.dart';

void main() {
test("Dart version test helper", () {
expect(atLeastDart("2.15.0"), true);
expect(atLeastDart("999.0.0"), false);
});

print("Testing basics of ObjectBox using C lib V${libraryVersion()}");

// Prior to Dart 2.6, the exception wasn't accessible and may have crashed.
Expand Down
12 changes: 5 additions & 7 deletions objectbox_test/test/box_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,12 @@ void main() {
final object = TestEntity2()..value = 42;
final future = box.putQueuedAwaitResult(object);

if (Platform.isMacOS && notAtLeastDart('3.1.0')) {
if (Platform.isMacOS && !atLeastDart('3.1.0')) {
// Before Dart 3.1 an incorrect exception is thrown on macOS.
// FIXME Debugging
await future;
// expect(
// () async => await future,
// throwsA(
// predicate((e) => e is ObjectBoxException && e.message == '')));
expect(
() async => await future,
throwsA(
predicate((e) => e is ObjectBoxException && e.message == '')));
} else {
expect(
() async => await future,
Expand Down
4 changes: 2 additions & 2 deletions objectbox_test/test/test_env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ Matcher sameAsList<T>(List<T> list) => unorderedEquals(list);
Future<void> yieldExecution() async =>
await Future<void>.delayed(Duration.zero);

bool notAtLeastDart(String dartVersion) {
bool atLeastDart(String expectedLowestVersion) {
final dartVersion = RegExp('([0-9]+).([0-9]+).([0-9]+)')
.firstMatch(Platform.version)
?.group(0);
if (dartVersion != null && dartVersion.compareTo(dartVersion) < 0) {
if (dartVersion != null && dartVersion.compareTo(expectedLowestVersion) > 0) {
return true;
} else {
return false;
Expand Down

0 comments on commit b9d173d

Please sign in to comment.