From 00ccd139248e782cd8316eff65c26aed838c7e46 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 29 Dec 2014 18:44:20 -0200 Subject: Don't barf if read-question cdr is not a date --- sx-question.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sx-question.el b/sx-question.el index 03ebb4b..5ce5d7f 100644 --- a/sx-question.el +++ b/sx-question.el @@ -118,7 +118,8 @@ See `sx-question--user-read-list'." ;; Question already present. ((setq cell (assoc .question_id site-cell)) ;; Current version is newer than cached version. - (when (> .last_activity_date (cdr cell)) + (when (or (not (numberp (cdr cell))) + (> .last_activity_date (cdr cell))) (setcdr cell .last_activity_date))) ;; Question wasn't present. (t -- cgit v1.2.3 From 53fdb88732568fb9c9e5d682f88371e602064d42 Mon Sep 17 00:00:00 2001 From: Sean Allred Date: Fri, 2 Jan 2015 20:07:34 -0500 Subject: Add test file for state changes --- test/test-state.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/test-state.el diff --git a/test/test-state.el b/test/test-state.el new file mode 100644 index 0000000..32f52b2 --- /dev/null +++ b/test/test-state.el @@ -0,0 +1,12 @@ +(defmacro with-question-data (cell id &rest body) + (declare (indent 2)) + `(let ((,cell '((question_id . ,id) + (site_par . "emacs") + (last_activity_date . 1234123456)))) + ,@body)) + +(ert-deftest test-question-mark-read () + "00ccd139248e782cd8316eff65c26aed838c7e46" + (should + (with-question-data q nil + (sx-question--mark-read q)))) -- cgit v1.2.3 From 5332946380610d5166c2d7b517a817e021130edd Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sun, 4 Jan 2015 11:30:04 -0200 Subject: More tests --- test/test-state.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test-state.el b/test/test-state.el index 32f52b2..7af4a64 100644 --- a/test/test-state.el +++ b/test/test-state.el @@ -7,6 +7,16 @@ (ert-deftest test-question-mark-read () "00ccd139248e782cd8316eff65c26aed838c7e46" + (with-question-data q 10 + ;; Check basic logic. + (should (sx-question--mark-read q)) + (should (sx-question--read-p q)) + (should (not (setcdr (assq 10 (cdr (assoc "emacs" sx-question--user-read-list))) nil))) + ;; Don't freak out because the cdr was nil. + (should (not (sx-question--read-p q))) + (should (sx-question--mark-read q))) (should (with-question-data q nil + ;; Don't freak out because question_id was nil. (sx-question--mark-read q)))) + -- cgit v1.2.3