1c002567b8
Follow up to https://github.com/flutter/flutter/issues/152684 Change-Id: I9477ccae9f1eab63a800443c654ae3b348023d82 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382021 Commit-Queue: Ben Konyi <bkonyi@google.com> Auto-Submit: Ben Konyi <bkonyi@google.com> Commit-Queue: Derek Xu <derekx@google.com> Reviewed-by: Derek Xu <derekx@google.com>
63 lines
2.3 KiB
Dart
63 lines
2.3 KiB
Dart
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
|
// for details. 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:dds/dds.dart';
|
|
import 'package:test/test.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);
|
|
});
|
|
});
|
|
}
|