From 39a78ea40772a30678dcd947fc4b8735d356edfb Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Sun, 2 Nov 2014 12:02:46 -0500 Subject: Fix test cases re file persistence Every time the test was getting run, it would create the file, but not delete it. This meant that tests were not idempotent and artifacts from previous tests were persisting into the next ones. Use `make-temp-file' to let-bind `stack-filter-cache-file' to a temporary file. It is guaranteed to be empty when the tests begin. --- test/tests.el | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/test/tests.el b/test/tests.el index fa60364..9c9438d 100644 --- a/test/tests.el +++ b/test/tests.el @@ -77,20 +77,19 @@ '(1 2 3))))) (ert-deftest test-filters () - ;; Ensure the file is empty - (ignore-errors + (let ((stack-filter-cache-file (make-temp-file "stack-test-"))) + (should-error (stack-filter-store "names must be symbols" + "this is a filter")) + ;; basic use + (should (equal '((test . "filter")) + (stack-filter-store 'test "filter"))) + ;; aggregation + (should (equal '((test2 . "filter2") (test . "filter")) + (stack-filter-store 'test2 "filter2"))) + ;; mutation + (should (equal '((test2 . "filter2") (test . "filter-test")) + (stack-filter-store 'test "filter-test"))) + ;; clean up (note: the file should exist) (delete-file (stack-cache-get-file-name - stack-filter-cache-file))) - - (should-error (stack-filter-store "names must be symbols" - "this is a filter")) - ;; basic use - (should (equal '((test . "filter")) - (stack-filter-store 'test "filter"))) - ;; aggregation - (should (equal '((test2 . "filter2") (test . "filter")) - (stack-filter-store 'test2 "filter2"))) - ;; mutation - (should (equal '((test2 . "filter2") (test . "filter-test")) - (stack-filter-store 'test "filter-test")))) + stack-filter-cache-file)))) -- cgit v1.2.3