1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 05:50:26 +02:00

tests: Use pass-if-equal' in web-response.test'.

* test-suite/tests/web-response.test: Cleanup whitespace.  Use
  `pass-if-equal' when appropriate.
This commit is contained in:
Ludovic Courtès 2012-11-28 21:25:07 +01:00
parent c438cd7175
commit cb17c4422b

View file

@ -1,6 +1,6 @@
;;;; web-response.test --- HTTP responses -*- mode: scheme; coding: utf-8; -*- ;;;; web-response.test --- HTTP responses -*- mode: scheme; coding: utf-8; -*-
;;;; ;;;;
;;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. ;;;; Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc.
;;;; ;;;;
;;;; This library is free software; you can redistribute it and/or ;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public ;;;; modify it under the terms of the GNU Lesser General Public
@ -66,37 +66,33 @@ consectetur adipisicing elit,\r
(begin (begin
(set! r (read-response (open-input-string example-1))) (set! r (read-response (open-input-string example-1)))
(response? r))) (response? r)))
(pass-if "read-response-body" (pass-if "read-response-body"
(begin (begin
(set! body (read-response-body r)) (set! body (read-response-body r))
#t)) #t))
(pass-if (equal? (response-version r) '(1 . 1))) (pass-if-equal '(1 . 1) (response-version r))
(pass-if-equal 200 (response-code r))
(pass-if (equal? (response-code r) 200)) (pass-if-equal "OK" (response-reason-phrase r))
(pass-if (equal? (response-reason-phrase r) "OK")) (pass-if-equal (string->utf8 "abcdefghijklmnopqrstuvwxyz0123456789")
body)
(pass-if (equal? body
(string->utf8 (pass-if-equal "checking all headers"
"abcdefghijklmnopqrstuvwxyz0123456789"))) `((date . ,(string->date "Wed, 03 Nov 2010 22:27:07 +0000"
"~a, ~d ~b ~Y ~H:~M:~S ~z"))
(pass-if "checking all headers" (server . "Apache/2.0.55")
(equal? (accept-ranges . (bytes))
(response-headers r) (cache-control . ((max-age . 543234)))
`((date . ,(string->date "Wed, 03 Nov 2010 22:27:07 +0000" (expires . ,(string->date "Thu, 28 Oct 2010 15:33:13 GMT +0000"
"~a, ~d ~b ~Y ~H:~M:~S ~z")) "~a, ~d ~b ~Y ~H:~M:~S ~z"))
(server . "Apache/2.0.55") (vary . (accept-encoding))
(accept-ranges . (bytes)) (content-encoding . (gzip))
(cache-control . ((max-age . 543234))) (content-length . 36)
(expires . ,(string->date "Thu, 28 Oct 2010 15:33:13 GMT +0000" (content-type . (text/html (charset . "utf-8"))))
"~a, ~d ~b ~Y ~H:~M:~S ~z")) (response-headers r))
(vary . (accept-encoding))
(content-encoding . (gzip))
(content-length . 36)
(content-type . (text/html (charset . "utf-8"))))))
(pass-if "write then read" (pass-if "write then read"
(call-with-values (call-with-values
(lambda () (lambda ()
@ -111,16 +107,18 @@ consectetur adipisicing elit,\r
(lambda (r* body*) (lambda (r* body*)
(responses-equal? r body r* body*)))) (responses-equal? r body r* body*))))
(pass-if "by accessor" (pass-if-equal "by accessor"
(equal? (response-content-encoding r) '(gzip))))) '(gzip)
(response-content-encoding r))))
(with-test-prefix "example-2" (with-test-prefix "example-2"
(let* ((r (read-response (open-input-string example-2))) (let* ((r (read-response (open-input-string example-2)))
(b (read-response-body r))) (b (read-response-body r)))
(pass-if (equal? '((chunked)) (pass-if-equal '((chunked))
(response-transfer-encoding r))) (response-transfer-encoding r))
(pass-if (equal? b (pass-if-equal
(string->utf8 (string->utf8
(string-append (string-append
"Lorem ipsum dolor sit amet, consectetur adipisicing elit," "Lorem ipsum dolor sit amet, consectetur adipisicing elit,"
" sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")))))) " sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."))
b)))