Skip to content

Commit

Permalink
Ignore Remote Config errors in integration tests (#726)
Browse files Browse the repository at this point in the history
Should fix #725

---------

Co-authored-by: Jonas Sander <[email protected]>
  • Loading branch information
nilsreichardt and Jonas-Sander authored Aug 9, 2023
1 parent f448fe4 commit ad1f58b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion app/lib/main/plugin_initializations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:flutter/foundation.dart';
import 'package:purchases_flutter/purchases_flutter.dart';
import 'package:remote_configuration/remote_configuration.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:sharezone/main/sharezone.dart';
import 'package:sharezone_utils/platform.dart';
import 'package:streaming_shared_preferences/streaming_shared_preferences.dart';

Expand Down Expand Up @@ -84,7 +85,7 @@ class PluginInitializations {
// fetch the remote config in the background. The next time the app starts,
// the fetched remote config will be available.
await remoteConfiguration.activate();
unawaited(remoteConfiguration.fetch());
unawaited(_fetchRemoteConfig(remoteConfiguration));

return remoteConfiguration;
}
Expand All @@ -101,6 +102,24 @@ class PluginInitializations {
}
}

Future<void> _fetchRemoteConfig(RemoteConfiguration remoteConfiguration) async {
try {
await remoteConfiguration.fetch();
} catch (e) {
if (isIntegrationTest && PlatformCheck.isAndroid) {
if ('$e'.contains(
'[firebase_remote_config/internal] internal remote config fetch error')) {
log("Catched '$e'. Ignoring because we're running an integration test.");
// Sometimes the remote config fetch fails on Android integration tests,
// see https://github.com/SharezoneApp/sharezone-app/issues/725.
return;
}
}

rethrow;
}
}

Future<PluginInitializations> runPluginInitializations() async {
final futureRemoteConfiguration =
PluginInitializations.initializeRemoteConfiguration();
Expand Down
1 change: 1 addition & 0 deletions app/lib/main/sharezone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import 'package:sharezone_widgets/sharezone_widgets.dart';
/// * Firebase Messaging (throws SERVICE_NOT_AVAILABLE or AUTHENTICATION_FAILED
/// when running on device farm devices, see
/// https://github.com/SharezoneApp/sharezone-app/issues/420)
/// * Ignore Remote Config fetch failures on Android
bool isIntegrationTest = false;

/// StreamBuilder "above" the Auth and SharezoneApp.
Expand Down

0 comments on commit ad1f58b

Please sign in to comment.