SandboxCase.Sandbox.FunWithFlags (sandbox_case v0.4.0)

Copy Markdown View Source

Sandbox adapter for FunWithFlags. Works with vanilla FunWithFlags — no fork and no bytecode patching.

Isolation is provided by a custom persistence adapter, SandboxCase.Sandbox.FwfAdapter, which routes flag operations to an isolated per-test ETS table when a :fwf_sandbox marker is present in the process dictionary (or reachable via $callers), and delegates to the real adapter otherwise. This module manages the pool of ETS tables and the per-test checkout/checkin.

config :sandbox_case,
  sandbox: [fun_with_flags: true]

The host app must point FunWithFlags at the sandbox adapter and disable the cache in the test environment:

config :fun_with_flags, :persistence,
  adapter: SandboxCase.Sandbox.FwfAdapter,
  sandbox_real_adapter: FunWithFlags.Store.Persistent.Ecto,
  repo: MyApp.Repo

config :fun_with_flags, :cache, enabled: false

setup/1 validates this wiring and raises with guidance if it's missing or wrong, rather than letting flag isolation silently leak.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.