Dynamo.Connection.Test
Implementation of the Dynamo.Connection
behaviour used for testing.
Check Dynamo.Connection
for documentation of all available callbacks.
Note that, besides the functions required by Dynamo.Connection
,
this connection also implements a couple extra functions, like
sent_body/1
, to retrieve the sent body, and fetched/1
, to
retrieve fetched aspects, which are useful for testing.
Although a new connection can be created via:
Dynamo.Connection.Test.new(verb, path, body, peer)
In practice, a developer should simply use Dynamo.HTTP.Case
,
which provides some wrappers around testing:
conn(verb, path, body)
Check Dynamo.HTTP.Case
for more information on testing.
Functions summary
already_sent?(_conn) | Callback implementation of |
delete_req_header(key, conn) | Deletes a request header. |
fetched(arg1) | Returns all fetched aspects during a request. |
main(main, conn) | Sets the main module under test. |
new(method, path, body \\ "") | Initializes a connection to be used in tests. |
peer(peer, conn) | |
put_req_cookie(key, value, conn) | Sets the cookies to be read by the request. |
put_req_header(key, value, conn) | Sets a request header, overriding any previous value.
Both |
recycle(conn) | Recycles the connection to it can be used in a subsequent requests. |
req(method, path, body \\ "", conn) | Prepares the connection to do a new request on the
given |
Functions
peer(peer, conn)
Sourceput_req_header(key, value, conn)
Sets a request header, overriding any previous value.
Both key
and value
are converted to binary.
recycle(conn)
Recycles the connection to it can be used in a subsequent requests.
Reclycing the connection resets all assigns, privates and other response information but keeps mostly of request information intact.
Particularly, cookies sent in the response are moved to the request, so they can be used in upcoming requests.
req(method, path, body \\ "", conn)
Prepares the connection to do a new request on the
given path
with the given method
and body
.
This can be considered the counter-part of recycle (which is used to clean up the response).