Commit 6397c022 authored by Kate Lovett's avatar Kate Lovett Committed by Flutter GitHub Bot

Adding error handling for SocketExceptions to local comparator (#48517)

parent fca59175
...@@ -564,7 +564,15 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC ...@@ -564,7 +564,15 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
return FlutterSkippingGoldenFileComparator( return FlutterSkippingGoldenFileComparator(
baseDirectory.uri, baseDirectory.uri,
goldens, goldens,
'No network connection available for contacting Gold.', 'OSError occurred, could not reach Gold. '
'Switching to FlutterSkippingGoldenFileComparator.',
);
} on io.SocketException catch (_) {
return FlutterSkippingGoldenFileComparator(
baseDirectory.uri,
goldens,
'SocketException occurred, could not reach Gold. '
'Switching to FlutterSkippingGoldenFileComparator.',
); );
} }
......
...@@ -871,9 +871,19 @@ void main() { ...@@ -871,9 +871,19 @@ void main() {
final MockDirectory mockDirectory = MockDirectory(); final MockDirectory mockDirectory = MockDirectory();
when(mockDirectory.existsSync()).thenReturn(true); when(mockDirectory.existsSync()).thenReturn(true);
when(mockDirectory.uri).thenReturn(Uri.parse('/flutter')); when(mockDirectory.uri).thenReturn(Uri.parse('/flutter'));
when(mockSkiaClient.getExpectations())
.thenAnswer((_) => throw const OSError('Can\'t reach Gold'));
FlutterGoldenFileComparator comparator = await FlutterLocalFileComparator.fromDefaultComparator(
platform,
goldens: mockSkiaClient,
baseDirectory: mockDirectory,
);
expect(comparator.runtimeType, FlutterSkippingGoldenFileComparator);
when(mockSkiaClient.getExpectations()) when(mockSkiaClient.getExpectations())
.thenAnswer((_) => throw const OSError()); .thenAnswer((_) => throw const SocketException('Can\'t reach Gold'));
final FlutterGoldenFileComparator comparator = await FlutterLocalFileComparator.fromDefaultComparator( comparator = await FlutterLocalFileComparator.fromDefaultComparator(
platform, platform,
goldens: mockSkiaClient, goldens: mockSkiaClient,
baseDirectory: mockDirectory, baseDirectory: mockDirectory,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment