| Index: pkg/analysis_server/test/mocks.dart
|
| diff --git a/pkg/analysis_server/test/mocks.dart b/pkg/analysis_server/test/mocks.dart
|
| index 2940115619166587ef346e0661790d39c600cc14..1d0082ceb999cfe4605c4b955cadb3129499e026 100644
|
| --- a/pkg/analysis_server/test/mocks.dart
|
| +++ b/pkg/analysis_server/test/mocks.dart
|
| @@ -203,3 +203,85 @@ class MockAnalysisContext extends Mock implements AnalysisContext {
|
| class MockSource extends Mock implements Source {
|
| noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
| }
|
| +
|
| +
|
| +/**
|
| + * A [Matcher] that check that the given [Response] has an expected identifier
|
| + * and no error.
|
| + */
|
| +Matcher isResponseSuccess(String id) => new _IsResponseSuccess(id);
|
| +
|
| +/**
|
| + * A [Matcher] that check that there are no `error` in a given [Response].
|
| + */
|
| +class _IsResponseSuccess extends Matcher {
|
| + final String _id;
|
| +
|
| + _IsResponseSuccess(this._id);
|
| +
|
| + @override
|
| + Description describe(Description description) {
|
| + return description.addDescriptionOf(
|
| + 'response with identifier "$_id" and without error');
|
| + }
|
| +
|
| + @override
|
| + bool matches(item, Map matchState) {
|
| + Response response = item;
|
| + return response.id == _id && response.error == null;
|
| + }
|
| +
|
| + @override
|
| + Description describeMismatch(item, Description mismatchDescription,
|
| + Map matchState, bool verbose) {
|
| + Response response = item;
|
| + var id = response.id;
|
| + RequestError error = response.error;
|
| + mismatchDescription.add('has identifier "$id"');
|
| + if (error != null) {
|
| + mismatchDescription.add(' and has error $error');
|
| + }
|
| + return mismatchDescription;
|
| + }
|
| +}
|
| +
|
| +
|
| +/**
|
| + * A [Matcher] that check that the given [Response] has an expected identifier
|
| + * and has an error.
|
| + */
|
| +Matcher isResponseFailure(String id) => new _IsResponseFailure(id);
|
| +
|
| +/**
|
| + * A [Matcher] that check that there are no `error` in a given [Response].
|
| + */
|
| +class _IsResponseFailure extends Matcher {
|
| + final String _id;
|
| +
|
| + _IsResponseFailure(this._id);
|
| +
|
| + @override
|
| + Description describe(Description description) {
|
| + return description.addDescriptionOf(
|
| + 'response with identifier "$_id" and an error');
|
| + }
|
| +
|
| + @override
|
| + bool matches(item, Map matchState) {
|
| + Response response = item;
|
| + return response.id == _id && response.error != null;
|
| + }
|
| +
|
| + @override
|
| + Description describeMismatch(item, Description mismatchDescription,
|
| + Map matchState, bool verbose) {
|
| + Response response = item;
|
| + var id = response.id;
|
| + RequestError error = response.error;
|
| + mismatchDescription.add('has identifier "$id"');
|
| + if (error == null) {
|
| + mismatchDescription.add(' and has no error');
|
| + }
|
| + return mismatchDescription;
|
| + }
|
| +}
|
|
|