Search documentation of bb

# BB.Test.ParameterBridge (bb v0.8.0)

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

## Types

t()

## Functions

child_spec(init_arg)

Returns a specification to start this module under a 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)

# 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)