April 2024
Beginner to intermediate
224 pages
5h 7m
English
You’ll often want to test two different things with Oban: that jobs are enqueued properly and that jobs work as expected. Oban provides test helpers for each of these situations. We’ll first test that our StatusWorker job is enqueued when an outgoing SMS message is created.
When we create an SMS message in the PhoneApp.Conversations module, we conditionally create an Oban job based on whether the SMS message is outgoing or not. So, we need to test that certain SMS messages enqueue the StatusWorker job, but other SMS messages don’t enqueue a job.
We’ll use the Oban.Testing module[108] to verify that the create_sms_message/1 function works correctly.
Add the following code to the existing ConversationsTest ...
Read now
Unlock full access