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

How to easy fake cosmos client #19943

Open
mingqishao opened this issue Feb 3, 2023 · 4 comments
Open

How to easy fake cosmos client #19943

mingqishao opened this issue Feb 3, 2023 · 4 comments
Assignees
Labels
Cosmos feature-request This issue requires a new behavior in the product in order be resolved.
Milestone

Comments

@mingqishao
Copy link

mingqishao commented Feb 3, 2023

Feature Request

We are using azcosmos package to talk with CosmosDB. We are struggling with mock the cosmos client for unit test. I'm wonder if the azcosmos SDK could provide a easy way to mock.

I found a usefully example from Compute SDK as reference: https://github.com/Azure/azure-sdk-for-go/blob/fake_prototype/sdk/resourcemanager/compute/armcompute/README.md#fakes

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 3, 2023
@ealsur
Copy link
Member

ealsur commented Feb 13, 2023

@mingqishao If the fake package allows the creation of the Transport then it should be also available for azcosmos.

The Options on client creation let you set the Transport.

Just saw that the fakes is only available for ARM Compute. I wonder if this needs to be created for all SDKs?

@jhendrixMSFT Are there any other recommendations for external users to mock the transport or the SDKs?

@RickWinter RickWinter added Azure.Core feature-request This issue requires a new behavior in the product in order be resolved. labels Feb 15, 2023
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 15, 2023
@mingqishao
Copy link
Author

mingqishao commented Apr 5, 2023

I found a internal package in SDK github.com/Azure/azure-sdk-for-go/sdk/internal/mock. That will be very useful for us if you can expose this package. That allow use to easily mock any service's client.

@andrew-lis
Copy link

andrew-lis commented Feb 26, 2024

I don't want mocks. I want stubs for CosmosDb SDK
Fake implementations like the other MS team did:

or remove sealed keywords so we can make these fakes/stub by over selves.

@RickWinter RickWinter added this to the Backlog milestone Aug 9, 2024
@RickWinter RickWinter assigned Pilchie and unassigned jhendrixMSFT Jan 27, 2025
@RickWinter
Copy link
Member

@Pilchie The cosmos sdk is hand written and would need to hand write the fakes to support this scenario. Joel can give guidance on the implementation if your team decides to add fakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cosmos feature-request This issue requires a new behavior in the product in order be resolved.
Projects
None yet
Development

No branches or pull requests

6 participants