1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
(use gauche.test)
(use file.util)
(use srfi-1)
(test-start "scmail.config")
(use scmail.config-core)
(use scmail.config)
(test-module 'scmail.config)
(with-module
scmail.config
;; disable choosing old files.
(define (choose path) path))
(define temporary-directory (build-path (current-directory) "test.dot.scmail"))
(test* "scmail-config-default-file" #t
(string=?
(scmail-config-default-file)
(expand-path "~/.scmail/config")))
(test "scmail-config-set-directory!" #t
(lambda ()
(scmail-config-set-directory! temporary-directory)
#t))
(test* "scmail-config-default-file" #t
(string=?
(scmail-config-default-file)
(build-path temporary-directory "config")))
(test "scmail-config-make-directory" #t
(lambda ()
(scmail-config-make-directory)
(file-is-directory? temporary-directory)))
;; try again to check whether it works if the directory already existed.
(test "scmail-config-make-directory" #t
(lambda ()
(scmail-config-make-directory)
(file-is-directory? temporary-directory)))
(remove-directory* temporary-directory)
(test* "scmail-config" #t
(is-a? (scmail-config) <config>))
(test* "scmail-config-get-path" #t
(every (lambda (pair)
(let ((slot (car pair))
(path (build-path temporary-directory (cdr pair))))
(string=?
(scmail-config-get-path slot)
path)))
'(
(deliver-rules . "deliver-rules")
(refile-rules . "refile-rules")
(log-file . "log")
(token-table . "token-table.dbm")
(digest . "digest.dbm")
)))
(test "scmail-config-read" #t
(lambda ()
(scmail-config-read (build-path (current-directory)
"../dot.scmail/config.sample"))
(is-a? (scmail-config) <config>)))
(test* "scmail-config-get-path" #t
(every (lambda (pair)
(let ((slot (car pair))
(path (build-path (expand-path "~/.scmail")
(cdr pair))))
(string=?
(scmail-config-get-path slot)
path)))
'(
(deliver-rules . "deliver-rules")
(refile-rules . "refile-rules")
(log-file . "log")
(token-table . "token-table.dbm")
(digest . "digest.dbm")
)))
(test-end)
|