From 296f3e0fbb8d96124637594db0925d1d88e36ddc Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Wed, 18 Dec 2024 15:15:48 +0100 Subject: [PATCH] fix tests --- .../integration_test/vector_value_e2e.dart | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/packages/cloud_firestore/cloud_firestore/example/integration_test/vector_value_e2e.dart b/packages/cloud_firestore/cloud_firestore/example/integration_test/vector_value_e2e.dart index 7a929137acef..a31fa4aeca17 100644 --- a/packages/cloud_firestore/cloud_firestore/example/integration_test/vector_value_e2e.dart +++ b/packages/cloud_firestore/cloud_firestore/example/integration_test/vector_value_e2e.dart @@ -59,15 +59,18 @@ void runVectorValueTests() { DocumentReference> doc = await initializeTest('vector-value-empty'); - await doc.set({ - 'foo': const VectorValue([]), - }); - - DocumentSnapshot> snapshot = await doc.get(); - - VectorValue vectorValue = snapshot.data()!['foo']; - expect(vectorValue, isA()); - expect(vectorValue.toArray(), equals([])); + try { + await doc.set({ + 'foo': const VectorValue([]), + }); + fail('Should have thrown an exception'); + } catch (e) { + expect(e, isA()); + expect( + (e as FirebaseException).code.contains('invalid-argument'), + isTrue, + ); + } }); testWidgets('handles single dimension vector', (_) async { @@ -106,15 +109,19 @@ void runVectorValueTests() { DocumentReference> doc = await initializeTest('vector-value-max-plus-one'); - await doc.set({ - 'foo': VectorValue(maxPlusOneDimensions), - }); - - DocumentSnapshot> snapshot = await doc.get(); - - VectorValue vectorValue = snapshot.data()!['foo']; - expect(vectorValue, isA()); - expect(vectorValue.toArray(), equals(maxPlusOneDimensions)); + try { + await doc.set({ + 'foo': VectorValue(maxPlusOneDimensions), + }); + + fail('Should have thrown an exception'); + } catch (e) { + expect(e, isA()); + expect( + (e as FirebaseException).code.contains('invalid-argument'), + isTrue, + ); + } }); testWidgets('handles very large values in vector', (_) async {