Periodic.Test (parent v0.12.1) View Source

Helpers for testing a periodic job.

See the "Testing" section in Periodic documentation for details.

Link to this section Summary

Functions

Subscribes to telemetry events of the given scheduler.

Sends a tick signal to the given scheduler and waits for the job to finish.

Sends a tick signal to the given scheduler.

Link to this section Functions

Link to this macro

assert_periodic_event(telemetry_id, event, metadata \\ quote do _ end, measurements \\ quote do _ end)

View Source (macro)

Waits for the given telemetry event.

Specs

observe(any()) :: :ok

Subscribes to telemetry events of the given scheduler.

Link to this macro

refute_periodic_event(telemetry_id, event, metadata \\ quote do _ end, measurements \\ quote do _ end)

View Source (macro)

Asserts that the given telemetry event won't be emitted.

Link to this function

sync_tick(pid_or_name, timeout \\ :timer.seconds(5))

View Source

Specs

sync_tick(GenServer.server(), non_neg_integer() | :infinity) ::
  {:ok, job_exit_reason :: any()} | {:error, :job_not_started}

Sends a tick signal to the given scheduler and waits for the job to finish.

The function returns the job exit reason, or error if the job hasn't been started.

Specs

tick(GenServer.server()) :: :ok

Sends a tick signal to the given scheduler.

This function returns after the tick signal has been sent, and the job has been started. However, the function doesn't wait for the job to finish. If you want complete synchronism, use sync_tick/2