wceolin
I’m using Mox to mock some modules in my app. Usually, it works fine but I have a function that I’m calling inside FLAME.call/2 and it broke my mock:
FLAME.call(Zoonk.FLAME.ImageOptimization, fn ->
Zoonk.Storage.optimize!(key, args["size"] || 500)
end)
After I added it to FLAME.call/2, I started getting the following error:
** (Mox.UnexpectedCallError) no expectation defined for Zoonk.Storage.StorageAPIMock.optimize!/2 in process #PID<0.5593.0> with args ["16.png", 500]
(mox 1.1.0) lib/mox.ex:820: Mox.__dispatch__/4
(zoonk 0.1.0) lib/storage/storage_context.ex:177: Zoonk.Storage.optimize!/2
(flame 0.2.0) lib/flame/runner.ex:431: anonymous fn/3 in FLAME.Runner.remote_call/4
I’ve tried calling Mox.allow/3 in test_helper.ex but it didn’t work:
Mox.allow(Zoonk.Storage.StorageAPIMock, self(), fn ->
GenServer.whereis(Zoonk.FLAME.ImageOptimization)
end)
Any ideas how to make it work inside FLAME.call/2? Thanks!
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #ai
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
al2o3cr
Zoonk.FLAME.ImageOptimizationis the name of theFLAME.Poolprocess that manages runners. It receives a:checkoutmessage and returns the actual PID of the runner, which is what you’d need to share the mock with.wceolin
Thanks for the pointer but I’m not sure I understood it (sorry, I’m very new to Elixir). It looks like:
FLAME.Poolis the process that manages runners. That’s the process I need.:checkoutmessages that returns the PID I need.checkout_runnerfunction, which is called on the handle_call callback.Do I need to listen to a callback somewhere? Doing some GPT-driven research, it suggests I need to call
GenServer.call(:flame_pool, :checkout)but that doesn’t seem to return the correct PID. GPT isn’t very good with Elixir, unfortunately.I know I can probably use set_mox_global (that seems to be what the FLAME codebase is using) but I’d love to understand how this actually works because I feel a bit lost here.
al2o3cr
There are three processes involved here:
Moxfunctions and the code-under-testFLAME.Pool, namedZoonk.FLAME.ImageOptimizationZoonk.Storage.optimize!The
Mox.allowyou posted in the original post is sharing the mock with the second process, but it’s actually needed in the third.FLAME.call“checks out” a runner and then sends it work; doing a checkout outside of that will return a different runner process from the pool, so that won’t help.Your options, IMO, are:
FLAME.callin a function and using Mox to replace that. Then, test the code inside theFLAME.callseparately.wceolin
I see, thanks. I thought there was a way to get the PID of that third process to use with
Mox.allow.I was trying to avoid running tests synchronously. In my initial tests, the runtime doubled from 3s to 6s, but moving those sync tests to a separate module brought it back to 3s. It seems like the best option for now.