Godfrey
Good Day ,
I have a specific workflow with ,for example (Workers A,B and C) . So when worker A executes successfully, it records results which have to be used by worker B and C.
So now I want to do Unit testing on Worker B and C , how would you advise in going about that ? Because now when I run maybe a perform_job on my unit test , where will it get those recorded result since an Oban Unit test shouldn’t be hitting the DB , How do I make it pass ???
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sorentwo
If a job is relying on the output of another, then an integration test may be appropriate. You can test all of the jobs together with run_workflow/2:
If the logic in those jobs is complex or the test requires too much setup, you can inject data through the
args. The trick is usingargs_schemawith the:termtype, so you can stub any value:Then use
perform_job/3as you normally would in your test:mtunski
I don’t quite understand what you mean by saying “Oban Unit test shouldn’t be hitting the DB” - what’s wrong with that?
Anyway, in Surfer, we ended up doing the following:
completeddependency job (A) into the database, with all the meaningful meta fields pre-filled (e.g.workflow_id,name,recorded&return) where thereturnis manually set toOban.Pro.Utils.encode64(whatever).meta.workflow_idandmeta.deps = [job_a_name].drain_jobs. I guessperform_jobwould also do the trick here. The job B will then have access to the recorded results from job A when it executes.After wrapping it in some helpers, you can end up with something like this:
HataluliRandima
Hi , I saw you said you dont understand what is meant by “Oban Unit test shouldn’t be hitting the DB”, I saw on the hex docs . See attached screenshot.
sorentwo
The discrepancy seems to be around the term “unit”. Pure tests that don’t touch the db are a fine ideal, but the sandbox makes db interaction so quick and isolated that it’s not always worth it.
I’d argue that a workflow test, especially one that relies on fetching results of another job, should be tested with the database involved.
dimitarvp
Thanks for confirming it, I always use manual testing mode and almost never the inline one.
Godfrey
Hi @sorentwo , thank you for the response . So In what situation will you use the oban unit test? or recommend one .
mtunski
I always thought of that this way: these unit-test Oban helpers just call
Worker.process/perform, without inserting the job to the database to execute it, as Oban would “normally” do.But regardless of this behaviour, if the worker code (implementation in
process/perform) itself has to reach the database - and it has if it tries reading the results of a job it depends on - it’s something different and 100% legit.sorentwo
In this situation I would integration test the workflow (as described above).