Moxinet (moxinet v0.3.0)
Moxinet
helps you mock the internet at the HTTP layer
without sacrificing parallel testing.
Summary
Functions
Returns the header needed to be included in requests to the mock servers in order to support parallel runs.
Mocks a call for the passed module by defining a signature based on the pid, http method and path.
Turns a pid into a reference which could be used for indexing the signatures.
The start functions which will start the Moxinet
server.
Types
Functions
Returns the header needed to be included in requests to the mock servers in order to support parallel runs.
@spec expect( module(), http_method(), binary(), Moxinet.SignatureStorage.Mock.callback(), Moxinet.SignatureStorage.store_options() ) :: :ok
Mocks a call for the passed module by defining a signature based on the pid, http method and path.
Options:
pid
: The source pid that the mock will be applied for. Defaults toself()
times
: The amount of times the mock signature may be used. Defaults to1
storage
: The signature storage to be used. Defaults toMoxinet.SignatureStorage
Examples:
Moxinet.expect(MyMock, :get, "/path/to/resource", fn _body ->
%Moxinet.Response{status: 200, body: "My response body"}
end)
Turns a pid into a reference which could be used for indexing the signatures.
The start functions which will start the Moxinet
server.
You'd most likely want to put run this function from
your test_helper.exs
:
{:ok, _pid} = Moxinet.start(router: MyMockServer, port: 4010)
Options
router
: A reference to your mock server. Requiredport
: The port your mock server will run on. Requiredname
: Name of the moxinet supervisor. Defaults toMoxinet