Code Monkey home page Code Monkey logo

Comments (9)

mathieutu avatar mathieutu commented on June 14, 2024

In fact the role of the factory is to transform config, and pass it to a new valid Google/Redis/xxx object. So, in the tests, we should check that the object is really valid, and it received the proper configuration. By mocking the creation as actual, we don't test if the client was created properly.

I think this is the reason why the make -with-arguments method was considerated as a code smell.

from laravel-pubsub.

matthewgoslett avatar matthewgoslett commented on June 14, 2024

Thanks for reporting this.

We'll take a look and see if there's a neater way of constructing these objects without passing in custom configuration.

from laravel-pubsub.

mathieutu avatar mathieutu commented on June 14, 2024

Guys ? Some news ?

from laravel-pubsub.

etiennemarais avatar etiennemarais commented on June 14, 2024

HI @mathieutu. I am actually struggling a lot with this at the moment. You can see I asked the question on the internals channel.

I made a branch so long to try out a couple of things. I wanted to keep the nice aliases but also extract the configs for each dependency out. In the process of designing like a configuration provider type class that knows how to transform the dependencies for those three affected clients, redis, google pubsub and kafka but its proving hard because essentially we are ending up with a FactoryFacotry and that it the real code smell imho.

You can see in the comparison, the road that I want to take but I am hitting a wall where the config that the client needs to be initialised with is now not really testable.

What are your thoughts?

from laravel-pubsub.

mathieutu avatar mathieutu commented on June 14, 2024

Hi @etiennemarais!
I understand your problem. In fact as I said I think we should test the real object, created by the factory, and don't mock it. You pass a conf, and check at the end if it's a proper instance, an if it have the proper conf.

But, even if I think this could be better, @taylorotwell made a PR with a makeWith method which we will be alble to use soon, so problem will be solved anyway...

from laravel-pubsub.

etiennemarais avatar etiennemarais commented on June 14, 2024

Ye I saw that post he made on the internals main issue. I will make a PR this weekend to take a run at the config closure passing which is actually not too bad imo. We can review it together and make a call.

from laravel-pubsub.

etiennemarais avatar etiennemarais commented on June 14, 2024

Good news, Taylor implemented a makeWith method to bring back the old functionality. See Pull request. I will spend some time today to swap this out, or if you want make a PR @mathieutu then I will merge it in. It seems like this issue affected so many people that it worked in getting it back.

from laravel-pubsub.

mathieutu avatar mathieutu commented on June 14, 2024

Yep ! It's what I told you here : #6 (comment)

Ok, I'm a bit busy right now, but the first one with time make the PR make it, and warn the other on!
:)

from laravel-pubsub.

matthewgoslett avatar matthewgoslett commented on June 14, 2024

Thanks for the PR.

This is published in 2.0.3

from laravel-pubsub.

Related Issues (6)

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.