Skip to content

Commit

Permalink
test: flutter only test
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Aug 29, 2023
1 parent c64215c commit 18feb25
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
7 changes: 5 additions & 2 deletions firestore_rest/lib/src/firestore_rest_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import 'package:tekartik_http/http.dart';

import 'import.dart';

const restNullValue = 'NULL_VALUE';
const restRequestTime = 'REQUEST_TIME';

bool get debugRest => debugFirestoreRest; // devWarning(true); // false

/// Exported for strict debugging
Expand All @@ -44,7 +47,7 @@ dynamic dateOrTimestampValue(
}

Object? fromRestValue(FirestoreDocumentContext firestore, Value restValue) {
if (restValue.nullValue == 'NULL_VALUE') {
if (restValue.nullValue == restNullValue) {
return null;
} else if (restValue.stringValue != null) {
return restValue.stringValue;
Expand Down Expand Up @@ -83,7 +86,7 @@ Object? fromRestValue(FirestoreDocumentContext firestore, Value restValue) {
}

String? restValueToString(FirestoreDocumentContext firestore, Value restValue) {
if (restValue.nullValue == 'NULL VALUE') {
if (restValue.nullValue == restNullValue) {
return restValue.nullValue;
} else if (restValue.stringValue != null) {
return restValue.stringValue;
Expand Down
2 changes: 2 additions & 0 deletions firestore_rest/test/firestore_rest_io_test.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
@TestOn('vm')
library tekartik_firebase_rest.firestore_rest_io_test;

import 'package:tekartik_common_utils/common_utils_import.dart';
import 'package:tekartik_firebase_firestore_rest/firestore_rest.dart';
import 'package:tekartik_firebase_firestore_test/firestore_test.dart';
import 'package:test/test.dart';

import 'test_setup.dart';

Future main() async {
// debugFirestoreRest = devWarning(true);
skipConcurrentTransactionTests = true;
var context = await setup();
group('rest_io', () {
Expand Down
27 changes: 27 additions & 0 deletions firestore_test/lib/firestore_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,33 @@ void runApp(
data = (await docRef.get()).data;
expect(data, {'other_key': 'other_value'});
});
test('setDeleteSubMapField', () async {
var testsRef = getTestsRef()!;
var docRef = testsRef.doc('set_delete_field');
var data = <String, Object?>{
'some_key': 'some_value',
'sub': <String, Object?>{
'sub_key': 'sub_value',
'other': 'other_value'
}
};
await docRef.set(data);
data = (await docRef.get()).data;
expect(data, {
'some_key': 'some_value',
'sub': {'sub_key': 'sub_value', 'other': 'other_value'}
});

data = {
'sub': {'sub_key': FieldValue.delete}
};
await docRef.set(data, SetOptions(merge: true));
data = (await docRef.get()).data;
expect(data, {
'some_key': 'some_value',
'sub': {'other': 'other_value'}
});
}, skip: 'Not supported yet but on flutter...');
test('array', () async {
if (firestoreService.supportsFieldValueArray) {
var testsRef = getTestsRef()!;
Expand Down

0 comments on commit 18feb25

Please sign in to comment.