diff options
author | Sean Allred <code@seanallred.com> | 2014-11-02 12:02:46 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2014-11-02 12:06:10 -0500 |
commit | 39a78ea40772a30678dcd947fc4b8735d356edfb (patch) | |
tree | c257bdb5574b7802016b656ca88d618b2fcd2809 | |
parent | 72f5d07097b3f1530c40379d52606d3bc6856938 (diff) |
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.
-rw-r--r-- | test/tests.el | 29 |
1 files changed, 14 insertions, 15 deletions
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)))) |