-
Notifications
You must be signed in to change notification settings - Fork 3
ErlymockTCP
The mocked socket I wrote in a situation where the communication was test <-> code_under_test <-> external_service, where each "<->" was a TCP connection. Unless you have that third party connection needed, I'd recommend against using erlymock_tcp.
Mocking a TCP socket follows the same rules and ordering as mocking functions. Initialization sets up the mock by using strict, stub, and o_o calls. Strict calls must be called in the order that they are declared during initialization and only once each. Stub calls can be called in any order, but min_invocations <= number of calls <= max_invocations. The defaults are 0 and infinite, respectively. Out of order calls (o_o) are merely stub calls where min_invocations = max_invocations = 1.
For mocked tcp sockets, the default action is to do nothing.
- {reply,Binary} -- sends the Binary to the socket,
- {reply,Function} -- Function/1 is passed the binary sent to the socket, the response must be a binary to send back to the connection.
- {close} -- closes the connection.