Closed sixtusagbo closed 5 months ago
We will currently not make any changes to the http_service. Instead of mocking the request you can send an actual request in the tests as these apis are also maintained by us.
Okay, I've removed the mocks. I am sending actual requests now. I've completed test cases for codePaneVisibleStateProvider
Just like we have defined example request models in https://github.com/foss42/apidash/blob/main/test/request_models.dart, you need to add constants like the URL used in tests in https://github.com/foss42/apidash/blob/main/test/test_consts.dart
Also, use api.apidash.dev
not api.foss42.com
Okay Sir, I just updated the files now.
LGTM 🚀
PR Description
I was trying to mock the request made on the app by mocking the
http.request()
method because parts of it that makes the request usinghttp.Client
object and it needs to be replaced to avoid making actual requests in the case of unit and widget tests.I went through the code in
http_service.dart
and it does not accept as a parameterhttp.Client
object. AndcollectionStateNotifierProvider
does not accepthttp.Client
object as a parameter too. If it accepts a client object (as a parameter), anyone will be able to override the client when testing in order mock the http request or to unit test the servicehttp_service.dart
.Related Issues
Checklist
main
branch before making this PRflutter test
) and all tests are passingAdded/updated tests?
We encourage you to add relevant test cases.