Skip to content

Commit a66f02e

Browse files
Bogdanpjeapostrophe
authored andcommitted
seconds->gmt-bytes: add output tests
1 parent 04fc622 commit a66f02e

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

web-server-test/tests/web-server/private/response-test.rkt

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
make-temporary-file)
77
web-server/http
88
web-server/http/response
9+
(submod web-server/http/response testing)
910
(prefix-in compat0: web-server/compat/0/http/response-structs)
1011
"../util.rkt")
1112

@@ -178,20 +179,42 @@
178179
#"HEAD")
179180
#"HTTP/1.1 200 OK\r\nDate: REDACTED GMT\r\nLast-Modified: REDACTED GMT\r\nServer: Racket\r\nContent-Type: text/html; charset=utf-8\r\n\r\n"))))
180181

182+
(define seconds->gmt-bytes-tests
183+
(test-suite
184+
"seconds->gmt-bytes"
185+
186+
(check-equal?
187+
(seconds->gmt-bytes 0)
188+
#"Thu, 01 Jan 1970 00:00:00 GMT")
189+
(check-equal?
190+
(seconds->gmt-bytes 86400)
191+
#"Fri, 02 Jan 1970 00:00:00 GMT")
192+
(check-equal?
193+
(seconds->gmt-bytes (+ 86400 3600 193))
194+
#"Fri, 02 Jan 1970 01:03:13 GMT")
195+
(check-equal?
196+
(seconds->gmt-bytes (+ (* 30 86400) 3600 193))
197+
#"Sat, 31 Jan 1970 01:03:13 GMT")
198+
(check-equal?
199+
(seconds->gmt-bytes (+ (* 90 86400) (quotient 86400 2) 977))
200+
#"Wed, 01 Apr 1970 12:16:17 GMT")))
201+
181202
(define response-tests
182203
(test-suite
183204
"HTTP Responses"
184-
205+
185206
output-response-tests
186-
207+
187208
output-response/method-tests
188-
209+
210+
seconds->gmt-bytes-tests
211+
189212
(let ()
190213
(define tmp-file (make-temporary-file))
191-
(with-output-to-file tmp-file
214+
(with-output-to-file tmp-file
192215
(lambda ()
193216
(display
194-
(xexpr->string
217+
(xexpr->string
195218
`(html (head (title "A title"))
196219
(body "Here's some content!")))))
197220
#:exists 'truncate/replace)

0 commit comments

Comments
 (0)