Use setup/teardown.
authorueno <ueno>
Mon, 6 Dec 2004 09:25:32 +0000 (09:25 +0000)
committerueno <ueno>
Mon, 6 Dec 2004 09:25:32 +0000 (09:25 +0000)
lisp/test/test-riece-log.el

index ea03b55..aeeb256 100644 (file)
       (setq files (cdr files)))
     (delete-directory directory)))
 
-(luna-define-method test-riece-log-flashback ((case test-riece-log))
-  (let ((riece-log-directory
-        (expand-file-name (make-temp-name "test-riece-log")
+(luna-define-method lunit-test-case-setup ((case test-riece-log))
+  (setq riece-log-directory
+       (expand-file-name (make-temp-name "test-riece-log")
                           (if (featurep 'xemacs)
                               (temp-directory)
-                            temporary-file-directory)))
-       riece-addons)
-    (unwind-protect
-       (let ((dir (expand-file-name "riece" riece-log-directory))
-             (riece-log-flashback 2)
-             riece-log-directory-map)
-         (make-directory riece-log-directory)
-         (make-directory dir)
-         (write-region "03:14 <test> a b c\n" nil
-                       (expand-file-name "20380119.log" dir) t 0)
-         (write-region "03:14 <test> 1 2 3\n" nil
-                       (expand-file-name "20380118.log" dir) t 0)
-         (lunit-assert-2
-          case
-          (equal
-           "03:14 <test> 1 2 3 (2038/01/18)\n03:14 <test> a b c (2038/01/19)\n"
+                            temporary-file-directory))
+       test-riece-log-directory
+       (expand-file-name "riece" riece-log-directory))
+  (make-directory riece-log-directory)
+  (make-directory test-riece-log-directory)
+  (write-region "03:14 <test> a b c\n03:15 <test> a b c\n" nil
+               (expand-file-name "20380119.log" test-riece-log-directory)
+               t 0)
+  (write-region "03:14 <test> 1 2 3\n" nil
+               (expand-file-name "20380118.log" test-riece-log-directory)
+               t 0))
+
+(luna-define-method lunit-test-case-teardown ((case test-riece-log))
+  (test-riece-log-delete-directory riece-log-directory))
+
+(luna-define-method test-riece-log-flashback-1 ((case test-riece-log))
+  (let ((riece-log-flashback 3)
+       riece-log-directory-map)
+    (lunit-assert-2
+     case
+     (equal
+      (concat "03:14 <test> 1 2 3 (2038/01/18)\n"
+             "03:14 <test> a b c (2038/01/19)\n"
+             "03:15 <test> a b c (2038/01/19)\n")
+      (with-temp-buffer
+       (riece-log-flashback (riece-make-identity "#riece" ""))
+       (buffer-string))))))
+
+(luna-define-method test-riece-log-flashback-2 ((case test-riece-log))
+  (let ((riece-log-flashback t)
+       riece-log-directory-map)
+    (lunit-assert-2
+     case
+     (equal ""
            (with-temp-buffer
              (riece-log-flashback (riece-make-identity "#riece" ""))
-             (buffer-string)))))
-      (test-riece-log-delete-directory riece-log-directory))))
-    
+             (buffer-string))))))