You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not identical data returns success response, probably need to add strict data check to the FullHttpRequestMatcher
test('Not identical data and FullHttpRequestMatcher', () async {
var dio = Dio();
var dioAdapter = DioAdapter(dio: dio);
var path = '/abc';
var data = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5};
var dataExpected = {'a': 1, 'b': 2};
dioAdapter.onPost(
path,
(server) => server.reply(
200,
'OK',
),
data: dataExpected,
);
expect(
() async => await dio.post(path, data: data),
throwsA(isA<DioException>()),
);
});
HTTP mock test test Not identical data and FullHttpRequestMatcher [E]
Expected: throws <Instance of 'DioException'>
Actual: <Closure: () => Future<Response<dynamic>>>
Which: returned a Future that emitted Response<dynamic>:<OK>
The text was updated successfully, but these errors were encountered:
We could reason that as long as the required subset is present in the body the condition is fulfilled, as usually that's how most web servers will also evaluate if the request body is good or bad.
Maybe there is demand for a new request matcher that only allows strict body checks?
This is solved in #158 and will be available in the next release.
Usage:
dio =Dio(BaseOptions(contentType:Headers.jsonContentType));
dioAdapter =DioAdapter(
dio: dio,
matcher:constFullHttpRequestMatcher(needsExactBody:true),
);
needsExactBody is defaulting to false, so no change is needed for existing code.
Not identical data returns success response, probably need to add strict data check to the FullHttpRequestMatcher
The text was updated successfully, but these errors were encountered: