]> code.delx.au - gnu-emacs-elpa/blob - emacs-web-server-test.el
run test processes asynch
[gnu-emacs-elpa] / emacs-web-server-test.el
1 ;;; emacs-web-server-test.el --- Test the Emacs Web Server
2
3 ;; Copyright (C) 2013 Eric Schulte <schulte.eric@gmail.com>
4
5 ;; Author: Eric Schulte <schulte.eric@gmail.com>
6 ;; License: GPLV3 (see the COPYING file in this directory)
7
8 ;;; TODO: fill in these tests, and then write more
9
10 ;;; Code:
11 (require 'emacs-web-server)
12 (require 'cl-lib)
13 (eval-when-compile (require 'cl))
14 (require 'ert)
15
16 (defun ews-test-run-asynch (continuation program &rest program-args)
17 (let* ((buffer (generate-new-buffer "*ews-test-run-asynch*"))
18 (proc (apply #'start-process "ews-test" buffer program program-args)))
19 (set-process-sentinel proc
20 (lexical-let ((cont continuation)
21 (buf buffer))
22 (lambda (proc signal)
23 (when (memq (process-status proc) '(exit signal))
24 (funcall cont (prog1 (with-current-buffer buf
25 (buffer-string))
26 (kill-buffer buf)))))))))
27
28 (ert-deftest ews/keyword-style-handler ()
29 "Ensure that a simple keyword-style handler matches correctly."
30 (should t) ; should match one
31 (should-not nil) ; should not match another
32 )
33
34 (ert-deftest ews/function-style-handler ()
35 "Ensure that a function-style handler matches correctly."
36 (should t) ; should match one
37 (should-not nil) ; should not match another
38 )
39
40 (ert-deftest ews/removed-from-ews-servers-after-stop ()
41 (should t))
42
43 (ert-deftest ews/parse-many-headers ()
44 "Test that a number of headers parse successfully."
45 (should t))
46
47 (ert-deftest ews/parse-post-data ()
48 (let ((post-header
49 "POST / HTTP/1.1
50 User-Agent: curl/7.33.0
51 Host: localhost:8080
52 Accept: */*
53 Content-Length: 273
54 Expect: 100-continue
55 Content-Type: multipart/form-data; boundary=----------------f1270d0deb77af03
56
57 ------------------f1270d0deb77af03
58 Content-Disposition: form-data; name=\"date\"
59
60 Wed Dec 18 00:55:39 MST 2013
61
62 ------------------f1270d0deb77af03
63 Content-Disposition: form-data; name=\"name\"
64
65 \"schulte\"
66 ------------------f1270d0deb77af03--
67 "))
68 (should 'properly-parse-post-data)))