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
return FlutterSkippingGoldenFileComparator(
baseDirectory.uri,
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() {
final MockDirectory mockDirectory = MockDirectory();
when(mockDirectory.existsSync()).thenReturn(true);
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())
.thenAnswer((_) => throw const OSError());
final FlutterGoldenFileComparator comparator = await FlutterLocalFileComparator.fromDefaultComparator(
.thenAnswer((_) => throw const SocketException('Can\'t reach Gold'));
comparator = await FlutterLocalFileComparator.fromDefaultComparator(
platform,
goldens: mockSkiaClient,
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