Comments (3)
It seems that currently the request body check is not strict as this test on the matches_request_test.dart
will fail:
test('actual is a subset of expected', () {
const actual = {
'a': 'a',
'b': 'b',
'c': 'c',
};
const expected = {
'a': 'a',
'b': 'b',
};
expect(options.matches(actual, expected), false);
});
@LukaGiorgadze Is this behavior intended?
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?
from http-mock-adapter.
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: const FullHttpRequestMatcher(needsExactBody: true),
);
needsExactBody
is defaulting to false
, so no change is needed for existing code.
from http-mock-adapter.
@sebastianbuechler Yeh, that makes sense.
Adding a new checker that checks nested data like deep equal is worth it.
Thanks @katjai1
from http-mock-adapter.
Related Issues (20)
- Selective mocking HOT 11
- can i request to onDownload when add unit test ? HOT 2
- [v0.4.0] collection version conflict between the v0.4.0 and flutter_test HOT 9
- Lower the Dart SDK constraint to 2.15.0
- Let server return different responses HOT 7
- Using query parameters in response data generation HOT 2
- use tester.pump rather than Future.delayed to allow tests to run faster HOT 1
- Split up `MockServer` `reply` method into static and dynamic version HOT 11
- http_mock_adapter 0.5.0 conflicts with flutter_test collection version. HOT 8
- Async mocking not possible HOT 1
- Semantic release with github action HOT 2
- Add methods onDownload & onDownloadUri
- Library not compatible with flutter 3.16.0 - incorrect type definition HOT 3
- LDClient.get() was called before init()!
- Ability to mock whole API interface for local development without a need of a server. HOT 2
- Allow timeout simulations in replies HOT 2
- QUESTION: how to use dio.simpleGet HOT 2
- http_mock_adapter-0.4.4/lib/src/mixins/request_handling.dart:32:42: Error: A value of type 'FutureOr<List<int>>' can't be assigned to a variable of type 'List<int>'. HOT 1
- Latest registered callback is called when multiple HTTP methods have been mocked
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-mock-adapter.