Coder Social home page Coder Social logo

Mocking the noble9 sdk about nobl9-go HOT 4 CLOSED

nobl9 avatar nobl9 commented on June 14, 2024
Mocking the noble9 sdk

from nobl9-go.

Comments (4)

nieomylnieja avatar nieomylnieja commented on June 14, 2024 1

hey @shubhindia :)

Some context:

sdk.Client was designed with API versioning in mind, so direct API calls like CreateProject are located under sub-structs holding the logic for specific endpoints.

So sdk.Client.Objects holds endpoints for objects related API set, while sdk.Client.Objects.V1 is used to access v1 versions of this API. Each returns a concrete struct without any means to change it's output, so enabling you to mock these would require some changes on our side, as you pointed out.

I need to think about it, I'll get back to you once I have an idea.

from nobl9-go.

nieomylnieja avatar nieomylnieja commented on June 14, 2024 1

Totally understandable :) I've already got a POC set up, I'll also add some docs which explain how to best/most easily mock the Client.

from nobl9-go.

shubhindia avatar shubhindia commented on June 14, 2024

hey @shubhindia :)

Some context:

sdk.Client was designed with API versioning in mind, so direct API calls like CreateProject are located under sub-structs holding the logic for specific endpoints.

So sdk.Client.Objects holds endpoints for objects related API set, while sdk.Client.Objects.V1 is used to access v1 versions of this API. Each returns a concrete struct without any means to change it's output, so enabling you to mock these would require some changes on our side, as you pointed out.

I need to think about it, I'll get back to you once I have an idea.

Thanks @nieomylnieja.

Currently we are just doing CRUD over Projects so its manageable but we can't just keep on writing WrapperFunctions for calling ActualClientFunctions as API grows. I mean we can but it's not really feasible.

from nobl9-go.

nieomylnieja avatar nieomylnieja commented on June 14, 2024

hey @shubhindia, happy to announce that v0.80.0 ships with an adjusted sdk.Client API which allows mocking the entire client.

I've also included an example/documentation on how to achieve that: https://github.com/nobl9/nobl9-go/tree/main/docs/mock_example.

I hope this meets your needs :) Let me know If you have any more questions on that and If it solved your issue!

from nobl9-go.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.