Adding error handling for SocketExceptions to local comparator (#48517)
This commit is contained in:
committed by
Flutter GitHub Bot
parent
fca5917519
commit
6397c022bb
@@ -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());
|
||||
final FlutterGoldenFileComparator comparator = await FlutterLocalFileComparator.fromDefaultComparator(
|
||||
.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 SocketException('Can\'t reach Gold'));
|
||||
comparator = await FlutterLocalFileComparator.fromDefaultComparator(
|
||||
platform,
|
||||
goldens: mockSkiaClient,
|
||||
baseDirectory: mockDirectory,
|
||||
|
||||
Reference in New Issue
Block a user