Managoat.Sandbox.Fake (managoat_sandbox v0.1.0)

Copy Markdown View Source

A real, in-memory Managoat.Sandbox adapter.

It lives under lib/, not test/support, on purpose: it is compiled in every environment so that a host application's own suite can run Managoat.Sandbox.ConformanceCase against it, drive a provisioning path without a network, or register it in the adapter map — the same way Ecto.Adapters.SQL.Sandbox ships inside Ecto rather than beside it.

Three jobs:

  • prove the conformance suite is not Sprites-shaped — a second adapter has to pass it;
  • exercise the owner-message contract for real — commands are actual processes emitting the {:stdout | :stderr | :exit, %{ref: ref}, _} frames, where most tests hand-craft them and can silently drift;
  • be the reference implementation the next adapter's author reads.

Commands speak a tiny scripted vocabulary instead of a shell — each arg is an instruction:

  • "out:<data>" / "err:<data>" — emit a stdout/stderr frame
  • "exit:<code>" — emit the exit frame and stop
  • "stay" — keep running: echo stdin writes back as echo:<data> stdout frames, exit 0 on stdin EOF
  • "drop" — the transport closes without an exit frame; per the contract the adapter must surface that as exit 0

A script with no terminal instruction exits 0. State lives in a named Agent; call reset/0 in a setup block. Sessions buffer every emitted frame, and attach/3 replays the buffer from the start before tailing — the load-bearing semantic the conformance suite pins.

Summary

Functions

The file contents written at path, or nil.

The network policy last applied to name, or nil.

Functions

file(name, path)

The file contents written at path, or nil.

policy(name)

The network policy last applied to name, or nil.

reset()