diff options
author | Sean Allred <code@seanallred.com> | 2014-11-02 18:25:41 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2014-11-02 18:25:41 -0500 |
commit | 0ecf1dcfb01be97e0d98416dc8e0e2bc1664daeb (patch) | |
tree | 04741375a35e87c25a5e3da91c153e15c483b2c6 /test/tests.el | |
parent | 6766f1175ac3fad1a2928ff1f798e9c11caf465d (diff) | |
parent | e089914f96caf5e1a74acb75995634c34455a290 (diff) |
Merge pull request #6 from vermiculus/precompiled-filters
Precompiled filters
Diffstat (limited to 'test/tests.el')
-rw-r--r-- | test/tests.el | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/test/tests.el b/test/tests.el index 44b0de0..e097244 100644 --- a/test/tests.el +++ b/test/tests.el @@ -5,25 +5,27 @@ (if (string-prefix-p "stack-" (symbol-name symbol)) (unintern symbol))))) +;;; Tests + (defun stack-test-sample-data (method &optional directory) - (with-current-buffer - (find-file-noselect - (concat "data-samples/" - (when directory (concat directory "/")) - method ".el")) - (eval (read (if (string-equal "" (buffer-string)) - "'no-value" - (buffer-string)))))) + (let ((file (concat "data-samples/" + (when directory (concat directory "/")) + method ".el"))) + (when (file-exists-p file) + (with-temp-buffer + (insert-file-contents file) + (read (buffer-string)))))) -(setq stack-test-data-questions - (stack-test-sample-data "questions") - stack-test-data-sites - (stack-test-sample-data "sites")) +(setq + stack-core-remaining-api-requests-message-threshold 50000 + debug-on-error t + stack-core-silent-requests nil + user-emacs-directory "." -;;; Tests - -(setq stack-core-remaining-api-requests-message-threshold 50000) -(setq debug-on-error t) + stack-test-data-questions + (stack-test-sample-data "questions") + stack-test-data-sites + (stack-test-sample-data "sites")) (require 'stack-core) (require 'stack-question) @@ -75,3 +77,21 @@ ((should-not-go)) ((1 . alpha) (2 . beta))] '(1 2 3))))) + +(ert-deftest test-filters () + (let ((stack-cache-directory (make-temp-file "stack-test" t))) + (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)))) |