[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e3e2608 6/8: Add test for a simple JSON post
From: |
Stefan Monnier |
Subject: |
[elpa] master e3e2608 6/8: Add test for a simple JSON post |
Date: |
Mon, 30 Mar 2020 09:06:29 -0400 (EDT) |
branch: master
commit e3e260844ae7259f9e5f490d00772f18e5b1697c
Author: jcaw <address@hidden>
Commit: jcaw <address@hidden>
Add test for a simple JSON post
Want to ensure we can post JSON, and access it in the handler.
---
web-server-test.el | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/web-server-test.el b/web-server-test.el
index 01e08f8..7ea02fa 100644
--- a/web-server-test.el
+++ b/web-server-test.el
@@ -184,6 +184,39 @@
org=-+one%0A-+two%0A-+three%0A-+four%0A%0A&beg=646&end=667&path=%2Fcomplex.org")
"org=-+one%0A-+two%0A-+three%0A-+four%0A%0A&beg=646&end=667&path=%2Fcomplex.org"))))
(ws-stop server))))
+(ert-deftest ws/parse-json-data ()
+ "Ensure we can send arbitrary data through to the handler
+
+The handler can then parse it itself."
+ (let ((server (ws-start nil ws-test-port))
+ (request (make-instance 'ws-request)))
+ (unwind-protect
+ (progn
+ (setf (pending request)
+ "POST /complex.org HTTP/1.1
+Host: localhost:4444
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101
Firefox/26.0
+Accept: */*
+Accept-Language: en-US,en;q=0.5
+Accept-Encoding: gzip, deflate
+DNT: 1
+Content-Type: application/json
+Referer: http://localhost:4444/complex.org
+Content-Length: 33
+Cookie: __utma=111872281.1462392269.1345929539.1345929539.1345929539.1
+Connection: keep-alive
+Pragma: no-cache
+Cache-Control: no-cache
+
+{\"some example\": \"json data\"}")
+ (ws-parse-request request)
+ (let ((headers (cdr (headers request))))
+ (should (string= (cdr (assoc :CONTENT-TYPE headers))
+ "application/json"))
+ (should (string= (oref request body)
+ "{\"some example\": \"json data\"}")))
+ (ws-stop server)))))
+
(ert-deftest ws/simple-post ()
"Test a simple POST server."
(ws-test-with
- [elpa] master updated (c7480d7 -> b0d5113), Stefan Monnier, 2020/03/30
- [elpa] master 7110ffa 1/8: Make network processes synchronous, Stefan Monnier, 2020/03/30
- [elpa] master 7071410 4/8: Store CONTENT-TYPE header - don't skip it, Stefan Monnier, 2020/03/30
- [elpa] master ae2587e 5/8: Extend simple POST test to check content-type and body, Stefan Monnier, 2020/03/30
- [elpa] master e3e2608 6/8: Add test for a simple JSON post,
Stefan Monnier <=
- [elpa] master 33afdb4 7/8: Bump version to 0.1.2, Stefan Monnier, 2020/03/30
- [elpa] master b0d5113 8/8: Merge commit '33afdb46e1cd61251736816d965495525b36c9cd', Stefan Monnier, 2020/03/30
- [elpa] master ca7e796 3/8: Add slot for the body of a request, Stefan Monnier, 2020/03/30
- [elpa] master cafa5b7 2/8: In old Emacs, :nowait t (overabundance of caution), Stefan Monnier, 2020/03/30