PaperTiger.Plugs.Sandbox (PaperTiger v1.0.2)

Copy Markdown View Source

Plug that extracts test namespace from HTTP headers for sandbox isolation.

When a request includes the x-paper-tiger-namespace header, this plug sets the namespace in the process dictionary so that all PaperTiger operations scope data to that namespace.

Usage in Tests

# In your test setup
setup :checkout_paper_tiger

# When making HTTP requests, include the namespace header
Req.post(url,
  headers: [
    {"authorization", "Bearer sk_test_mock"},
    {"x-paper-tiger-namespace", inspect(self())}
  ]
)

# Or use the helper from PaperTiger.Test
Req.post(url, headers: PaperTiger.Test.sandbox_headers())

How It Works

  1. Client sends x-paper-tiger-namespace header with the test PID as a string
  2. This plug parses the PID and sets it in the process dictionary
  3. All subsequent store operations in this request use that namespace
  4. Data is isolated from other concurrent tests

Summary

Functions

call(conn, opts)

init(opts)