Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): integrate each test #10

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
plugins:
firebase_core: ["tv-7.0"]
firebase_database: ["tv-7.0"]
firebase_storage: ["tv-7.0"]
cloud_functions: ["tv-7.0"]
tests: ["tv-7.0"]

This file was deleted.

38 changes: 38 additions & 0 deletions packages/tests/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# VS Code related
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

3 changes: 3 additions & 0 deletions packages/tests/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Flutterfire test

All package e2e tests belong in this application.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:cloud_functions_example/firebase_options.dart';
import 'package:tests/firebase_options.dart';

import 'sample_data.dart' as data;

Expand Down
22 changes: 22 additions & 0 deletions packages/tests/example/integration_test/e2e_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2022, 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.

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'cloud_functions/cloud_functions_e2e_test.dart' as cloud_functions;
import 'firebase_core/firebase_core_e2e_test.dart' as firebase_core;
import 'firebase_database/firebase_database_e2e_test.dart' as firebase_database;
import 'firebase_storage/firebase_storage_e2e_test.dart' as firebase_storage;

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('FlutterFire', () {
firebase_core.main();
firebase_database.main();
cloud_functions.main();
firebase_storage.main();
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:firebase_core_platform_interface/firebase_core_platform_interfac
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import '../lib/firebase_options.dart';
import 'package:tests/firebase_options.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:tests/firebase_options.dart';

import '../lib/firebase_options.dart';
import 'instance_e2e.dart';
import 'list_result_e2e.dart';
import 'reference_e2e.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tests/firebase_options.dart';

import '../lib/firebase_options.dart';
import 'test_utils.dart';

void setupInstanceTests() {
Expand Down Expand Up @@ -241,9 +241,10 @@ void setupInstanceTests() {
});

test('toString', () {
// flutterfire-e2e-tests.appspot.com -> mytest-16eac.appspot.com
expect(
storage.toString(),
'FirebaseStorage(app: [DEFAULT], bucket: flutterfire-e2e-tests.appspot.com)',
'FirebaseStorage(app: [DEFAULT], bucket: mytest-16eac.appspot.com)',
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@
import 'dart:convert';
import 'dart:io';

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:tests/firebase_options.dart';
import './test_utils.dart';

void setupReferenceTests() {
group('$Reference', () {
late FirebaseStorage storage;

setUpAll(() async {
storage = FirebaseStorage.instance;
// Create a new app due to options initialization conflict
// with the default app in another package.
FirebaseApp app = await Firebase.initializeApp(
name: "storage",
options: DefaultFirebaseOptions.baseOptions,
);
storage = FirebaseStorage.instanceFor(app: app);
});

group('bucket', () {
Expand Down Expand Up @@ -460,7 +467,8 @@ void setupReferenceTests() {
test('toString', () async {
expect(
storage.ref('/uploadNope.jpeg').toString(),
equals('Reference(app: [DEFAULT], fullPath: uploadNope.jpeg)'),
equals(
'Reference(app: storage, fullPath: uploadNope.jpeg)'), // [DEFAULT] -> storage
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import 'dart:math';

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';

import '../lib/firebase_options.dart';
import 'package:tests/firebase_options.dart';

final String kTestString =
([]..length = int.parse('${pow(2, 12)}')).join(_getRandomString(8)) * 100;
Expand Down
59 changes: 59 additions & 0 deletions packages/tests/example/lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2022, 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.

// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, TargetPlatform;

/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
switch (defaultTargetPlatform) {
case TargetPlatform.linux:
// Note: To find out if you are using the Tizen platform, refer to the link below.
// https://github.com/flutter-tizen/flutter-tizen/issues/482#issuecomment-1441139704
return tizen;
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}

// For firebase_storage test
static FirebaseOptions get baseOptions {
return FirebaseOptions(
apiKey: 'PLACEHOLDER',
appId: 'PLACEHOLDER',
messagingSenderId: 'PLACEHOLDER',
projectId: 'PLACEHOLDER',
databaseURL: 'PLACEHOLDER',
storageBucket: 'PLACEHOLDER',
);
}

static const FirebaseOptions tizen = FirebaseOptions(
apiKey: 'PLACEHOLDER',
appId: 'PLACEHOLDER',
messagingSenderId: 'PLACEHOLDER',
projectId: 'PLACEHOLDER',
databaseURL: 'PLACEHOLDER',
storageBucket: 'PLACEHOLDER',
);

static String get emulatorHost {
return 'PLACEHOLDER';
}
}
Loading
Loading