Skip to content
This repository was archived by the owner on May 13, 2023. It is now read-only.
This repository was archived by the owner on May 13, 2023. It is now read-only.

Mock SupabaseClient. #12

Closed
Closed
@happy-san

Description

@happy-san

Feature request

Is your feature request related to a problem? Please describe.

Working on a little side-project to make a Todo app. It would be awesome to have a mock client to unit test my Repository class.

Describe the solution you'd like

A MockSupabaseClient that'll be useful for unit testing the code (similar to the MockClient from http package).

Describe alternatives you've considered

Tried to create a mock, but got stuck since this gives me called select('task, status') on null. Also since SupabaseQueryBuilder isn't exposed, I can't mock the response of from('todos').

void main() {
  TodoRepository repo;
  final mockClient = MockSupabaseClient();

  setUp(() {
    when(mockClient.from('todos').select('task, status').execute()).thenAnswer(
      (_) => Future.value(
        PostgrestResponse(
          data: [
            {'task': 't1', 'status': true},
            {'task': 't2', 'status': false},
          ],
          status: 200,
          error: null,
          count: null,
        ),
      ),
    );

    repo = TodoRepository(mockClient);
  });

  //...
}

I can help with this feature but I'll need some guidance along the way. Please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions