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

[FR] Fake WeaviateClient implementation #103

Open
fidsusj opened this issue Dec 8, 2023 · 0 comments
Open

[FR] Fake WeaviateClient implementation #103

fidsusj opened this issue Dec 8, 2023 · 0 comments

Comments

@fidsusj
Copy link

fidsusj commented Dec 8, 2023

When writing unit tests for a class having a WeaviateClient object as a dependency, one usually tries to mock away the real database connection by using a WeaviateClient mock object instead. Mocking can normally be easily achieved using frameworks like ts-mockito.

import { anyString, instance, mock, when } from 'ts-mockito'

...

const mockClient = mock<WeaviateClient>()
const mockClientInstance = instance(mockClient)

const mockSchema = mock<Schema>()
const mockSchemaInstance = instance(mockSchema)

when(mockClient.schema).thenReturn(mockSchemaInstance)

when(mockSchema.exists(anyString())).thenReturn(Promise.resolve(true))

However, this typescript client makes use of the Builder Pattern heavily, which makes mocking an entire WeaviateClient implementation quite cumbersome.

For developers, it would therefore be convenient to have a fake in-memory WeaviateClient implementation provided by the typescript client library itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant