ExAtlas.Providers.Mock (ExAtlas v0.5.0)

Copy Markdown View Source

In-memory provider for tests and demos.

Every ExAtlas.Provider callback is implemented against an ETS-backed store. Useful for:

  • Unit tests that need a full provider without hitting the network.
  • Local development of LiveView UIs that spawn compute.
  • Validating that your user code is provider-agnostic (swap :runpod for :mock and everything should still work).

The mock is not intended for production use. It simulates state transitions synchronously — pods are :running immediately after spawn_compute/2, jobs complete on the next get_job/2.

Usage

config :ex_atlas, default_provider: :mock
config :ex_atlas, :mock, api_key: "anything"

{:ok, compute} = ExAtlas.spawn_compute(gpu: :h100, image: "test", auth: :bearer)
{:ok, _}       = ExAtlas.get_compute(compute.id)
:ok            = ExAtlas.terminate(compute.id)

Resetting between tests

setup do
  ExAtlas.Providers.Mock.reset()
  :ok
end

Summary

Functions

Ensure the ETS table exists. Called automatically by every callback.

Clear all mock state. Call from test setup.

Functions

ensure_started()

Ensure the ETS table exists. Called automatically by every callback.

reset()

Clear all mock state. Call from test setup.