Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
Fix a couple test timeouts.
Browse files Browse the repository at this point in the history
R=rnystrom@google.com

Review URL: https://codereview.chromium.org//864983002
  • Loading branch information
nex3 committed Jan 22, 2015
1 parent 0c84044 commit 809dba9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/server/batch_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void main() {
{'jsonrpc': '2.0', 'method': 'foo'},
{'jsonrpc': '2.0', 'method': 'id', 'params': ['value']},
{'jsonrpc': '2.0', 'method': 'arg', 'params': {'arg': 'value'}}
]), completion(isNull));
]), doesNotComplete);
});

test('returns an error if the batch is empty', () {
Expand Down
2 changes: 1 addition & 1 deletion test/server/server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void main() {
'jsonrpc': '2.0',
'method': 'foo',
'params': {}
}), completion(isNull));
}), doesNotComplete);
});

test("includes the error data in the response", () {
Expand Down
14 changes: 14 additions & 0 deletions test/server/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ void expectErrorResponse(ServerController controller, request, int errorCode,
})));
}

/// Returns a matcher that matches [Future]s that never complete.
Matcher get doesNotComplete => predicate((future) {
future.then(expectAsync((_) {
// This will never be called. [expectAsync] with `count: 0` ensures that an
// error will be thrown when [future] completes.
}, count: 0));

// Make sure there's enough time in the test for [expectAsync] to fail if it's
// going to.
expect(pumpEventQueue(), completes);

return true;
});

/// Returns a matcher that matches a [json_rpc.RpcException] with an
/// `invalid_params` error code.
Matcher throwsInvalidParams(String message) {
Expand Down

0 comments on commit 809dba9

Please sign in to comment.