53 lines
1.6 KiB
Racket
53 lines
1.6 KiB
Racket
#lang racket/base
|
|
|
|
(require rackunit
|
|
racket/port
|
|
"../mimetypes.rkt"
|
|
"../private/mime-types.rkt")
|
|
|
|
(define sample-types
|
|
(string-append
|
|
"# comment\n"
|
|
"text/plain txt text\n"
|
|
"audio/mpeg mp3\n"
|
|
"# application/example\n"))
|
|
|
|
(define parsed
|
|
(call-with-input-string sample-types parse-mime-types))
|
|
|
|
(check-equal? (hash-ref parsed 'txt) "text/plain")
|
|
(check-equal? (hash-ref parsed 'text) "text/plain")
|
|
(check-equal? (hash-ref parsed 'mp3) "audio/mpeg")
|
|
|
|
(define duplicate-extension
|
|
(call-with-input-string
|
|
(string-append
|
|
"application/x-ms-wmz wmz\n"
|
|
"application/x-msmetafile wmf wmz emf emz\n")
|
|
parse-mime-types))
|
|
|
|
(check-equal? (hash-ref duplicate-extension 'wmz)
|
|
"application/x-msmetafile")
|
|
|
|
(parameterize ([updates-enabled? #f])
|
|
(check-equal? (mimetype-for-ext 'MP3) "audio/mpeg")
|
|
(check-equal? (mimetype-for-ext ".MP3") "audio/mpeg")
|
|
(check-equal? (mimetype-for-ext "track.MP3") "audio/mpeg")
|
|
(check-equal? (mimetype-for-ext "/music/track.MP3") "audio/mpeg")
|
|
(check-equal? (mimetype-for-ext (string->path "track.MP3"))
|
|
"audio/mpeg")
|
|
(check-equal? (mimetype-for-ext "track.opus") "audio/ogg")
|
|
(check-equal? (mimetype-for-ext "movie.mp4") "video/mp4")
|
|
(check-equal? (mimetype-for-ext "unknown"
|
|
#:default "unknown/type")
|
|
"unknown/type"))
|
|
|
|
(check-false
|
|
(update-due?/times 1000 (- 1000 success-interval -1) #f))
|
|
(check-true
|
|
(update-due?/times 1000 (- 1000 success-interval 1) #f))
|
|
(check-false
|
|
(update-due?/times 1000 #f (- 1000 failure-interval -1)))
|
|
(check-true
|
|
(update-due?/times 1000 #f (- 1000 failure-interval 1)))
|