Skip to content

Commit

Permalink
elnode-mock-con: new macro wraps fakir-mock-process
Browse files Browse the repository at this point in the history
elnode-test-access-log: replace fakir-mock-process with elnode-mock-con
  • Loading branch information
nicferrier committed Aug 10, 2014
1 parent ba75246 commit 56c49a7
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions elnode-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,29 @@ is just a test helper."
(apply 'format `(,err-message ,@err-include)))
(buffer-substring (point-min) (point-max))))))))

(defmacro elnode-mock-con (symbol bindings &rest body)
"Mock an HTTP connection.
This is a simple extension of `fakir-mock-process'. It does
exactly what that does except it additionally sets up the elnode
property hashtable on the process plist."
(declare (debug (sexp sexp &rest form))
(indent defun))
`(fakir-mock-process ,symbol ,bindings
(progn
(set-process-plist ,symbol (list (make-hash-table :test 'eq)))
,@body)))

(ert-deftest elnode-test-access-log ()
"Test the access logging."
(fakir-mock-process :httpcon
(elnode-mock-con :httpcon
((:buffer
(elnode--http-make-hdr
'get "/"
'(host . "localhost")
'(user-agent . "test-agent")))
(:elnode-httpresponse-status 200)
(:elnode-bytes-written 2048))
(set-process-plist :httpcon (list (make-hash-table :test 'eq)))
(elnode/con-put :httpcon
:elnode-http-started (current-time)
:elnode-httpresponse-status 200
Expand Down

0 comments on commit 56c49a7

Please sign in to comment.