Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest registered callback is called when multiple HTTP methods have been mocked #172

Open
orevial opened this issue May 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@orevial
Copy link
Contributor

orevial commented May 3, 2024

Description

When registering the same route with different HTTP methods, it seems that the latest registered route always takes precedence, no matter what HTTP method is used.

Steps to reproduce

First I register the same route twice, but on different methods.

  dioAdapter.onGet(
    '/settings',
    (server) {
      server.reply(
        200,
        '{"data": {"some": "settings"}}',
      );
    },
  );
  dioAdapter.onPatch(
    '/settings',
    (server) {
      server.reply(
        200,
        '',
      );
    },
  );

Then in my test I try to make the HTTP call:

dio.get('/settings');

But when I do that I get the second call from the patch callback whereas I would expect the get callback to be called instead.

Expected behavior

The adapter should only match the route if the HTTP method is the one being called.

Additional context

  • http_mock_adapter: ^0.6.1
  • Flutter 3.19.5
@orevial orevial added the bug Something isn't working label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant