detour v0.1.0 Detour

Link to this section Summary

Functions

Returns the detour struct associated with the current process.

Starts a Detour server.

Stops a running Detour server.

Link to this section Types

Link to this type

message_t()

message_t() :: {binary(), [binary()], binary()}
Link to this type

t()

t() :: %Detour{pid: pid() | nil, port: pos_integer()}

Link to this section Functions

Link to this function

get()

get() :: t()

Returns the detour struct associated with the current process.

Link to this function

open(opts \\ [])

open(Keyword.t()) :: t() | {:error, term()}

Starts a Detour server.

You can specify a port by providing a value to the :port option. If a port isn't provided then a random open port will be used. Note that it is preferrable to have Detour assign a port for you. When assigning a static port you run into the risk of address conflicts and limits your ability to run tests asynchronously.

Returns a %Detour{} struct that will contain the assigned port. You can pass this port to your SMTP client with a relay of localhost to direct all SMTP traffic to Detour.

Link to this function

shutdown(detour, opts \\ [])

shutdown(t(), Keyword.t()) :: :ok | {:error, :not_found}

Stops a running Detour server.

Stopping a Detour server will release it's port making it available for another process. When providing a port to open/1 it's important to perform a shutdown, otherwise test processes using the same port can conflict.