Chronicle.Test (chronicle v0.1.2)

Copy Markdown

Lightweight capture and inspection helpers for application tests.

{result, entries} =
  Chronicle.Test.capture(fn audit_opts ->
    Accounts.disable(account, audit_opts)
  end)

assert result == :ok
assert Chronicle.Test.event?(entries, "account.disabled")

Capture does not mutate application configuration or install hidden routing. Pass the supplied options to audit calls, including spawned work:

Chronicle.Test.capture(fn audit_opts ->
  Task.async(fn -> Chronicle.record!("job.started", %{}, audit_opts) end)
  |> Task.await()
end)

Summary

Functions

capture(fun)

@spec capture((keyword() -> result)) :: {result, [Chronicle.Provider.Memory.entry()]}
when result: term()

event?(entries, type, predicate \\ fn _event -> true end)

events(entries)

group?(entries, type, predicate \\ fn _group -> true end)

groups(entries)