BB.Test.ParameterBridge (bb v0.15.3)

Copy Markdown View Source

Reference implementation of BB.Bridge for testing.

Records all calls for test assertions and provides controllable responses.

Usage

# Start robot with bridge
start_supervised!(RobotWithBridge)
bridge_pid = BB.Process.whereis(RobotWithBridge, :test_bridge)

# Register to receive change notifications
BB.Test.ParameterBridge.register_test_process(bridge_pid, self())

# Simulate inbound requests from remote
{:ok, params} = BB.Test.ParameterBridge.list_params(bridge_pid)
{:ok, value} = BB.Test.ParameterBridge.get_param(bridge_pid, [:speed])
:ok = BB.Test.ParameterBridge.set_param(bridge_pid, [:speed], 2.0)

# Receive outbound change notifications
assert_receive {:bridge_change, %BB.Parameter.Changed{}}

Summary

Functions

Returns a specification to start this module under a supervisor.

Clear recorded calls.

Get all recorded calls.

Get a parameter value (simulates inbound request from remote).

List all parameters (simulates inbound request from remote).

Register a test process to receive change notifications.

Set a parameter value (simulates inbound request from remote).

Set up fake remote parameters for testing inbound remote access.

Simulate a remote parameter change (for testing subscriptions).

Types

t()

@type t() :: %BB.Test.ParameterBridge{
  calls: [{atom(), list()}],
  remote_params: %{required(BB.Bridge.param_id()) => term()},
  robot: module(),
  subscriptions: MapSet.t(BB.Bridge.param_id()),
  test_pid: pid() | nil
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear_calls(pid)

Clear recorded calls.

get_calls(pid)

Get all recorded calls.

get_param(pid, path)

Get a parameter value (simulates inbound request from remote).

list_params(pid, prefix \\ nil)

List all parameters (simulates inbound request from remote).

register_test_process(pid, test_pid)

Register a test process to receive change notifications.

set_param(pid, path, value)

Set a parameter value (simulates inbound request from remote).

set_remote_params(pid, params)

Set up fake remote parameters for testing inbound remote access.

simulate_remote_change(pid, param_id, value)

Simulate a remote parameter change (for testing subscriptions).

start_link(opts)