Description
I would like to simulate a 401 http error with DioAdapter. If I set a response to DioException in onPostrequestHandlerCallback, I gave this exception:
dart:isolate _RawReceivePort._handleMessage
TimeoutException after 0:00:30.000000: Test timed out after 30 seconds. See https://pub.dev/packages/test#timeouts
Steps to reproduce
test(
'When login call failed with 401, returns a InvalidCredentialsException',
() async {
dioAdapter.onPost(
url,
(server) => server.throws(
401,
DioException.badResponse(
statusCode: 401,
requestOptions: RequestOptions(path: url),
response: Response(
statusCode: 401,
requestOptions: RequestOptions(path: url),
),
),
),
data: requestJsonBody
);
expect(() async => await remoteApi.login(email, password),
throwsA(InvalidCredentialsException()));
});
Expected behavior
Expect an exception.
System details
0.6.1 http_mock_adapter
Flutter 3.16
Additional context
If I remove the Response part from DioException, it works fine, but cannot simulate my API because I need a response with 401 status code. I tried without badResponse constructor, but still worked wrong. During debugging, the break point was going to dio.post call and after this timeouted.
Description
I would like to simulate a 401 http error with DioAdapter. If I set a response to DioException in onPostrequestHandlerCallback, I gave this exception:
dart:isolate _RawReceivePort._handleMessage
TimeoutException after 0:00:30.000000: Test timed out after 30 seconds. See https://pub.dev/packages/test#timeouts
Steps to reproduce
test(
'When login call failed with 401, returns a InvalidCredentialsException',
() async {
dioAdapter.onPost(
url,
(server) => server.throws(
401,
DioException.badResponse(
statusCode: 401,
requestOptions: RequestOptions(path: url),
response: Response(
statusCode: 401,
requestOptions: RequestOptions(path: url),
),
),
),
data: requestJsonBody
);
Expected behavior
Expect an exception.
System details
0.6.1 http_mock_adapter
Flutter 3.16
Additional context
If I remove the Response part from DioException, it works fine, but cannot simulate my API because I need a response with 401 status code. I tried without badResponse constructor, but still worked wrong. During debugging, the break point was going to dio.post call and after this timeouted.