Cronex v0.4.0 Cronex.Test

This module defines helpers for testing cron jobs definition.

Summary

Macros

Checks if a job with the specified frequency and time is defined inside the given scheduler

Checks if a job with the specified interval, frequency and time is defined inside the given scheduler

Macros

assert_job_every(frequency, opts)

Checks if a job with the specified frequency and time is defined inside the given scheduler.

time (optional) and scheduler should be passed inside opts as a keyword list.

You can also specify how many jobs with the given frequency and time should be defined using the count parameter inside the opts list. It defaults to 1.

Example

# Asserts if an every hour job is defined in MyApp.Scheduler
assert_job_every :hour, in: MyApp.Scheduler

# Asserts if an every day job at 10:00 is defined in MyApp.Scheduler
assert_job_every :day, at: "10:00", in: MyApp.Scheduler

# Asserts if 3 every day jobs at 10:00 are defined in MyApp.Scheduler
assert_job_every :day, at: "10:00", in: MyApp.Scheduler, count: 3
assert_job_every(interval, frequency, opts)

Checks if a job with the specified interval, frequency and time is defined inside the given scheduler.

time (optional) and scheduler should be passed inside opts as a keyword list.

You can also specify how many jobs with the given frequency and time should be defined using the count parameter inside the opts list. It defaults to 1.

Example

# Asserts if an every hour job is defined in MyApp.Scheduler
assert_job_every 2, :hour, in: MyApp.Scheduler

# Asserts if an every day job at 10:00 is defined in MyApp.Scheduler
assert_job_every 3, :day, at: "10:00", in: MyApp.Scheduler

# Asserts if 3 every day jobs at 10:00 are defined in MyApp.Scheduler
assert_job_every 3, :day, at: "10:00", in: MyApp.Scheduler, count: 3