AuditTrail.Adapters.Test (audit_trail v0.1.1)

Copy Markdown

In-memory storage adapter for tests. Accumulates every pushed log in an ETS table instead of shipping it anywhere, so a test suite can assert on what got logged without a running Loki/Postgres.

# config/test.exs
config :audit_trail,
  enabled:         true,
  storage_adapter: AuditTrail.Adapters.Test,
  batch_size:      1   # flush every log immediately instead of waiting
                        # for flush_interval (default 2000ms) — without
                        # this, AuditTrail.Test's assertions will likely
                        # time out waiting for the periodic flush

Pair with AuditTrail.Test.assert_logged/2 / assert_not_logged/2. Call AuditTrail.Test.clear/0 in setup to reset between tests — this is a single shared table, so tests relying on it should run with async: false.

Summary

Functions

All captured logs, raw and atom-keyed, oldest first.

Clears every captured log.

Functions

all()

All captured logs, raw and atom-keyed, oldest first.

clear()

Clears every captured log.