View Source EfxCase.MockState (Efx v0.1.7)

This module implements a global mutable state needed for mocking.

Mocking works by adding the pid of the mock-owning process to it's dictionary and accessing this pid using a lookup with ProcessTree.

The pid then can be used to lookup information of the mock, e.g. which function is mocked with replacement or how often a function was called to verify. This module is the global lookup.

We need a global lookup in which we can manipulate data to count mock invocations as well as store mocks as global when a test is flagged as async.

Summary

Types

@type pid_t() :: pid() | :global

Functions

Link to this function

add_fun(behaviour, fun_identifier, arity, fun, num_expected_calls)

View Source
@spec add_fun(module(), atom(), arity(), (... -> any()), non_neg_integer() | nil) ::
  :ok
Link to this function

add_fun(pid, behaviour, fun_identifier, arity, fun, num_expected_calls)

View Source
@spec add_fun(
  pid_t(),
  module(),
  atom(),
  arity(),
  (... -> any()),
  non_neg_integer() | nil
) :: :ok
Link to this function

call(behaviour, fun_identifier, args)

View Source
@spec call(module(), atom(), [any()]) :: function_return :: any()
Link to this function

call(pid, behaviour, fun_identifier, args)

View Source
@spec call(pid_t(), module(), atom(), [any()]) :: function_return :: any()

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec clean_globals() :: :ok
@spec mocked?(module()) :: boolean()
@spec mocked?(pid_t(), module()) :: boolean()
@spec parse([EfxCase.Mock.MockedFun.t()]) :: String.t()
@spec verify_called!() :: no_return() | nil | :ok
@spec verify_called!(pid_t()) :: no_return() | nil | :ok