Skip to content

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

@orevial

Description

@orevial

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions