]> code.delx.au - gnu-emacs-elpa/commitdiff
testing a hello-world server
authorEric Schulte <schulte.eric@gmail.com>
Fri, 20 Dec 2013 04:06:06 +0000 (21:06 -0700)
committerEric Schulte <schulte.eric@gmail.com>
Fri, 20 Dec 2013 04:06:30 +0000 (21:06 -0700)
emacs-web-server-test.el

index 594d0c27bae56f2f49ec4e4573a1f9e9a59bfa12..efe0cb303d63c14ff00ed1d9ff45eacc72c6178b 100644 (file)
                                    (buffer-string))
                             (kill-buffer buf)))))))))
 
+(defvar ews-test-port 8999)
+
+(ert-deftest ews/hello-world-server ()
+  "Test that a simple hello-world server responds."
+  (lexical-let
+      ((server
+        (ews-start
+         '(((lambda (_) t) .
+            (lambda (proc request)
+              (ews-response-header proc 200 '("Content-type" . "text/plain"))
+              (process-send-string proc "hello world")
+              :finished)))
+         ews-test-port)))
+    (ews-test-run-asynch
+     (lambda (response)
+       (should (string= response "hello world"))
+       (ews-stop server))
+     "curl" "-s" (format "localhost:%d" ews-test-port))))
+
 (ert-deftest ews/keyword-style-handler ()
   "Ensure that a simple keyword-style handler matches correctly."
   (should t)                            ; should match one