Skip to content

Commit

Permalink
refactor(firebase_functions): e2e tests null safety
Browse files Browse the repository at this point in the history
  • Loading branch information
pr-Mais committed Nov 19, 2021
1 parent b8d607c commit 0b0a261
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
6 changes: 3 additions & 3 deletions packages/cloud_functions/cloud_functions/example/pubspec.yaml
Expand Up @@ -2,8 +2,8 @@ name: cloud_functions_example
description: Demonstrates how to use the cloud_functions plugin.

environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.12.13+hotfix.4"
sdk: '>=2.12.0 <3.0.0'
flutter: '>=1.12.13+hotfix.4'

dependencies:
cloud_functions:
Expand All @@ -27,7 +27,7 @@ dependency_overrides:
path: ../../../firebase_core/firebase_core_web

dev_dependencies:
drive: 0.1.0
drive: ^1.0.0-1.0.nullsafety.1
flutter_driver:
sdk: flutter
test: any
Expand Down
@@ -1,12 +1,7 @@
// ignore_for_file: require_trailing_commas
// @dart = 2.9

// Copyright 2020, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

import 'package:cloud_functions/cloud_functions.dart';
import 'package:drive/drive.dart' as drive;
import 'package:firebase_core/firebase_core.dart';
Expand All @@ -20,7 +15,8 @@ String kTestFunctionTimeout = 'testFunctionTimeout';
String kTestMapConvertType = 'testMapConvertType';

void testsMain() {
HttpsCallable callable;
late HttpsCallable callable;

setUpAll(() async {
await Firebase.initializeApp();
FirebaseFunctions.instance.useFunctionsEmulator('localhost', 5001);
Expand Down Expand Up @@ -85,15 +81,16 @@ void testsMain() {
});

test(
'[HttpsCallableResult.data] should return Map<String, dynamic> type for returned objects',
() async {
HttpsCallable callable =
FirebaseFunctions.instance.httpsCallable(kTestMapConvertType);
'[HttpsCallableResult.data] should return Map<String, dynamic> type for returned objects',
() async {
HttpsCallable callable =
FirebaseFunctions.instance.httpsCallable(kTestMapConvertType);

var result = await callable();
var result = await callable();

expect(result.data, isA<Map<String, dynamic>>());
});
expect(result.data, isA<Map<String, dynamic>>());
},
);
});

group('FirebaseFunctionsException', () {
Expand All @@ -107,7 +104,7 @@ void testsMain() {
expect(e.message, equals('Invalid test requested.'));
return;
} catch (e) {
fail(e);
fail('$e');
}
});

Expand All @@ -122,18 +119,21 @@ void testsMain() {
} on FirebaseFunctionsException catch (e) {
expect(e.code, equals('cancelled'));
expect(
e.message,
equals(
'Response data was requested to be sent as part of an Error payload, so here we are!'));
e.message,
equals(
'Response data was requested to be sent as part of an Error payload, so here we are!',
),
);
expect(e.details, equals(data.deepMap));
} catch (e) {
fail(e);
fail('$e');
}
});
});

group('region', () {
HttpsCallable customRegionCallable;
late HttpsCallable customRegionCallable;

setUpAll(() async {
customRegionCallable =
FirebaseFunctions.instanceFor(region: 'europe-west1')
Expand All @@ -147,12 +147,13 @@ void testsMain() {
});

group('HttpsCallableOptions', () {
HttpsCallable timeoutCallable;
late HttpsCallable timeoutCallable;

setUpAll(() async {
timeoutCallable = FirebaseFunctions.instance.httpsCallable(
kTestFunctionTimeout,
options: HttpsCallableOptions(timeout: const Duration(seconds: 3)));
kTestFunctionTimeout,
options: HttpsCallableOptions(timeout: const Duration(seconds: 3)),
);
});

test('times out when the provided timeout is exceeded', () async {
Expand All @@ -164,7 +165,7 @@ void testsMain() {
} on FirebaseFunctionsException catch (e) {
expect(e.code, equals('deadline-exceeded'));
} catch (e) {
fail(e);
fail('$e');
}
});
});
Expand Down
@@ -1,5 +1,4 @@
// ignore_for_file: require_trailing_commas
// @dart = 2.9

// Copyright 2020, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
Expand Down
@@ -1,5 +1,4 @@
// ignore_for_file: require_trailing_commas
// @dart = 2.9

// Copyright 2020, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
Expand Down

0 comments on commit 0b0a261

Please sign in to comment.