Open AmitThakkar opened 10 months ago
Is there any plan to provide mocks so users can morally write tests?
I don't think there was any discussion around this. Do you have examples of other libraries doing the same?
I'm not against the idea 🤔
Hello @ArthurSens,
Thanks for looking into my request.
Here are a few examples:
Not all libraries include a mocks directory with pre-made mock implementations. However, many Go libraries follow a convention where they include mock implementations alongside their regular codebase, often in a mock directory or a similarly named one.
+1 I was just looking for this You can use a tool like https://github.com/uber-go/mock to easily auto-gen it
👋🏽
Interesting topic. I am not immediately opposed, but wanted to give perspective on why generally maintaining mocks next to the backend API tend to be controversial topic:
Initially, when I started working with Go I was mocking fun. But with time, it's just not productive to mock everything and every detail, unless you write software for NASA.
I would be more curious if a simple "Prometheus fake" would be a better use of our time e.g. where somebody could combine client_golang Prometheus API client with some code that allows injecting a simple array of series and PromQL responses.
@bwplotka Those are good points. Fakes are indeed preferable to mocks when possible. I also see your point about there not being a standard mocking framework, that indeed throws a wrench into things.
Apidog may be able to solve your problem,is a free platform or tool that allows you to import an API definition and generate mock data for testing and development purposes. Its "Smart Mock" feature can generate mock data automatically based on the names of fields, allowing you to create realistic-looking mock data without having to manually specify the values for each field.
Hello,
I am using this library to interact with Prometheus and realized the mocks are missing for the API interface.
Is there any plan to provide mocks so users can morally write tests?
Thanks,