forked from firka/flutter
[flutter_tools] handle OsError thrown during azure detector (#64749)
This commit is contained in:
@@ -119,6 +119,9 @@ class AzureDetector {
|
||||
// The HttpClient connected to a host, but it did not respond in a timely
|
||||
// fashion. Assume we are not on a bot.
|
||||
return _isRunningOnAzure = false;
|
||||
} on OSError {
|
||||
// The HttpClient might be running in a WSL1 environment.
|
||||
return _isRunningOnAzure = false;
|
||||
}
|
||||
// We got a response. We're running on Azure.
|
||||
return _isRunningOnAzure = true;
|
||||
|
||||
@@ -148,6 +148,14 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWithoutContext('isRunningOnAzure returns false when OsError is thrown', () async {
|
||||
when(mockHttpClient.getUrl(any)).thenAnswer((_) {
|
||||
throw const OSError('Connection Refused', 111);
|
||||
});
|
||||
|
||||
expect(await azureDetector.isRunningOnAzure, isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('isRunningOnAzure returns true when azure metadata is reachable', () async {
|
||||
when(mockHttpClient.getUrl(any)).thenAnswer((_) {
|
||||
return Future<HttpClientRequest>.value(mockHttpClientRequest);
|
||||
|
||||
Reference in New Issue
Block a user