From 2b92a1741fa0ef1fae3adddc1ac62ba2111cd532 Mon Sep 17 00:00:00 2001 From: Uwe <13865709+greenrobot-team@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:25:12 +0200 Subject: [PATCH] Tests: macOS now correctly throws unique violation exception. Follow-up from ccec6e8f unblock macOS CI failure --- objectbox_test/test/box_test.dart | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/objectbox_test/test/box_test.dart b/objectbox_test/test/box_test.dart index f41ef31f..e5e3e740 100644 --- a/objectbox_test/test/box_test.dart +++ b/objectbox_test/test/box_test.dart @@ -1,7 +1,5 @@ // ignore_for_file: deprecated_member_use -import 'dart:io'; - import 'package:objectbox/objectbox.dart'; import 'package:test/test.dart'; @@ -240,18 +238,11 @@ void main() { final object = TestEntity2()..value = 42; final future = box.putQueuedAwaitResult(object); - try { - await future; - } catch (e) { - // TODO: Mac in GitHub CI (not locally reproducible yet)... - if (Platform.isMacOS) { - expect(e is ObjectBoxException, isTrue); - expect((e as ObjectBoxException).message, ''); - } else { - expect(e is UniqueViolationException, isTrue); - expect(e.toString(), contains('Unique constraint')); - } - } + expect( + () async => await future, + throwsA(predicate((e) => + e is UniqueViolationException && + e.message.contains('Unique constraint')))); expect(object.id, isNull); // ID must remain unassigned }