From b4ac5e67f55147db98e17f9e2df8d7e044b6bcdf Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Thu, 1 Jan 2015 17:07:38 -0500 Subject: Remove redundant consing --- test/tests.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/tests.el') diff --git a/test/tests.el b/test/tests.el index d709600..53e053f 100644 --- a/test/tests.el +++ b/test/tests.el @@ -55,7 +55,7 @@ (defun sx-test-message (message &rest args) (when sx-test-enable-messages - (apply #'message (cons message args)))) + (apply #'message message args))) (mapc #'sx-load-test '(api macros printing util)) -- cgit v1.2.3 From 8b5e430d385db04b21b917bb62935e8266819e38 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Thu, 1 Jan 2015 23:13:17 -0500 Subject: Add tests for search functionality --- test/test-search.el | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test/tests.el | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/test-search.el (limited to 'test/tests.el') 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"])))) + diff --git a/test/tests.el b/test/tests.el index 53e053f..d06c0ff 100644 --- a/test/tests.el +++ b/test/tests.el @@ -58,4 +58,4 @@ (apply #'message message args))) (mapc #'sx-load-test - '(api macros printing util)) + '(api macros printing util search)) -- cgit v1.2.3 From b5e4da2a4b6f59e28b1aca11f7dad9323df1a8fe Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 2 Jan 2015 22:14:37 -0500 Subject: Don't display status messages from url during test --- test/tests.el | 1 + 1 file changed, 1 insertion(+) (limited to 'test/tests.el') diff --git a/test/tests.el b/test/tests.el index 53e053f..bb2f9f4 100644 --- a/test/tests.el +++ b/test/tests.el @@ -11,6 +11,7 @@ sx-initialized t sx-request-remaining-api-requests-message-threshold 50000 debug-on-error t + url-show-status nil user-emacs-directory "." sx-test-base-dir (file-name-directory (or load-file-name "./"))) -- cgit v1.2.3