mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Nullable types for values in map patterns require the key to be present. Since the 'uri' key is not always present in DDS exception responses, this was causing us to fall back to throwing a StateError. Fixes https://github.com/flutter/flutter/issues/152684
64 lines
2.2 KiB
Dart
64 lines
2.2 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter_tools/src/base/dds.dart';
|
|
|
|
import '../../src/common.dart';
|
|
|
|
void main() {
|
|
group('DartDevelopmentServiceException.fromJSON', () {
|
|
test('parses existing DDS instance error', () {
|
|
final DartDevelopmentServiceException actual =
|
|
DartDevelopmentServiceException.fromJson(
|
|
<String, Object>{
|
|
'error_code':
|
|
DartDevelopmentServiceException.existingDdsInstanceError,
|
|
'message': 'Foo',
|
|
'uri': 'http://localhost',
|
|
},
|
|
);
|
|
final DartDevelopmentServiceException expected =
|
|
DartDevelopmentServiceException.existingDdsInstance(
|
|
'Foo',
|
|
ddsUri: Uri.parse('http://localhost'),
|
|
);
|
|
expect(actual.errorCode, expected.errorCode);
|
|
expect(actual.message, expected.message);
|
|
expect(actual, isA<ExistingDartDevelopmentServiceException>());
|
|
expect(
|
|
(actual as ExistingDartDevelopmentServiceException).ddsUri,
|
|
(expected as ExistingDartDevelopmentServiceException).ddsUri,
|
|
);
|
|
});
|
|
|
|
test('parses connection issue error', () {
|
|
final DartDevelopmentServiceException actual =
|
|
DartDevelopmentServiceException.fromJson(
|
|
<String, Object>{
|
|
'error_code': DartDevelopmentServiceException.connectionError,
|
|
'message': 'Foo',
|
|
},
|
|
);
|
|
final DartDevelopmentServiceException expected =
|
|
DartDevelopmentServiceException.connectionIssue('Foo');
|
|
expect(actual.errorCode, expected.errorCode);
|
|
expect(actual.message, expected.message);
|
|
});
|
|
|
|
test('parses failed to start error', () {
|
|
final DartDevelopmentServiceException expected =
|
|
DartDevelopmentServiceException.failedToStart();
|
|
final DartDevelopmentServiceException actual =
|
|
DartDevelopmentServiceException.fromJson(
|
|
<String, Object>{
|
|
'error_code': DartDevelopmentServiceException.failedToStartError,
|
|
'message': expected.message,
|
|
},
|
|
);
|
|
expect(actual.errorCode, expected.errorCode);
|
|
expect(actual.message, expected.message);
|
|
});
|
|
});
|
|
}
|