OapiCodemode.Executor.Mock (oapi_codemode v0.5.0)

Copy Markdown View Source

Test executor: the "sandbox" is an Elixir function you set per test. Exercises the plumbing (globals in, callbacks out, results back) without a JS runtime.

set_response/1 takes fn code, env -> {:ok, %{value: _, logs: _}} end. There is no JS, so there is no host object to build: a test calls the named callbacks of env.callbacks directly, with the argument list the guest would have passed — env.callbacks.request.(["petstore", %{"method" => "GET", "path" => "/pets"}]), env.callbacks.describe.(["petstore", "createPet"]).

M7: this ships in lib/, not test/support/, on purpose — downstream hosts need it to test their own tool wiring without standing up a JS engine (hosts configure it as the executor for their whole test env).

Summary

Functions

set_response(fun)