diff options
author | Sean Allred <code@seanallred.com> | 2015-01-03 23:12:52 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2015-01-03 23:12:52 -0500 |
commit | b8f10ec2fb55df8851d253dfbdac79d8ddafccf6 (patch) | |
tree | 8598dc70212e458480719ee7c29e3d504a0d3aa0 /test/test-search.el | |
parent | 7069ab0b2374bf255425fca6705e85706645b643 (diff) | |
parent | 3753e7c15d6b8b16b76daa238418f71b0de49871 (diff) |
Merge branch 'master' into tag-bot
Diffstat (limited to 'test/test-search.el')
-rw-r--r-- | test/test-search.el | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/test-search.el b/test/test-search.el new file mode 100644 index 0000000..72dbcdc --- /dev/null +++ b/test/test-search.el @@ -0,0 +1,53 @@ +(defmacro test-with-bogus-string (cell &rest body) + "Let-bind a bogus string to CELL and execute BODY." + (declare (indent 1)) + `(let ((,cell "E7631BCF-A94B-4507-8F0C-02CFB3207F55")) + ,@body)) + + +(ert-deftest test-search-basic () + "Test basic search functionality" + (should + (sx-search-get-questions + "emacs" 1 "emacs"))) + +(ert-deftest test-search-empty () + "Test bogus search returns empty vector" + (test-with-bogus-string query + (should + (equal + [] + (sx-search-get-questions "emacs" 1 query))))) + +(ert-deftest test-search-invalid () + "Test invalid search" + (should-error + ;; @todo: test the interactive call + (sx-search + "emacs" nil nil ["emacs"]))) + +(ert-deftest test-search-full-page () + "Test retrieval of the full search page" + (should + (= 30 (length (sx-search-get-questions + "stackoverflow" 1 "jquery"))))) + +(ert-deftest test-search-exclude-tags () + "Test excluding tags from a search" + (should + (cl-every + (lambda (p) + (sx-assoc-let p + (not (member "org-export" .tags)))) + (sx-search-get-questions + "emacs" 1 nil "org-mode" "org-export"))) + (should + (cl-every + (lambda (p) + (sx-assoc-let p + (not (or (member "org-export" .tags) + (member "org-agenda" .tags))))) + (sx-search-get-questions + "emacs" 1 nil "org-mode" + ["org-export" "org-agenda"])))) + |