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

set gestalt global #3

Open
paulz opened this issue Jul 15, 2020 · 1 comment
Open

set gestalt global #3

paulz opened this issue Jul 15, 2020 · 1 comment

Comments

@paulz
Copy link

paulz commented Jul 15, 2020

First of all thank you for this open source library, we benefit from it every day!

We recently ran into a problem when we want to swap config variable for end to end tests. Since we do not know before hand the PID for started process we had fail to do it.

Would it be possible to use gestalt for all processes globally, similar as we do for Mox.set_mox_global:
https://hexdocs.pm/mox/Mox.html#set_mox_global/1 ?

Or is there another way we can swap config variables for all subsequent calls in tests?

@sax
Copy link
Member

sax commented Jul 15, 2020

Thanks for the feedback! It's very encouraging to hear.

So far I've tried to avoid the need for global mocks. For Phoenix with Wallaby, I do this: https://hexdocs.pm/gestalt/overview.html#acceptance-tests. One thing that I've done (in closed-source code, so I can't point you directly at it) is to put a delay between init and actual message handling in a GenServer, and run Gestalt.copy(test_pid, genserver_pid). So in my test I'll use start_supervised, grab the pid, and then swap over config for the genserver pid.

I think it would take me a while to figure out how to do a global override in a way that's safe, with my current workload. If you're not able to find a way to make an override for your pid, but were able to do a first pass at a pull request in the next day or two, it would be more likely that I'd be able to merge (or finish it up) than that I'd make the change from scratch.

If that's not viable, I'm likely more available after this week. I'm happy to continue this conversation in the meanwhile, to figure out the best way to implement this. Maybe something close to how Mox handles it internally?

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

2 participants