diff of 926b5d797aee820b2771fa50b78cece4f52acdd2
926b5d797aee820b2771fa50b78cece4f52acdd2
diff --git a/test/literal-test.lisp b/test/literal-test.lisp
index b1b2273..2d97d75 100644
--- a/test/literal-test.lisp
+++ b/test/literal-test.lisp
@@ -31,6 +31,10 @@
into just the quotation-wrapped code)))))
+(def-test lists-do-not-error ()
+ (is (equalp `(progn (format t "lol~%") (literal code ))
+ (macroexpand `(literal Dumb documentation (with a parenthesis-wrapped block) that 666 returns this !L (format t "lol~%") code )))))
+
(if (and (sb-ext:posix-getenv "GHA")
(not (run! 'literal-suite)))
diff --git a/test/literal.lisp b/test/literal.lisp
index 4af80ab..180a1de 100644
--- a/test/literal.lisp
+++ b/test/literal.lisp
@@ -16,7 +16,9 @@
(progn
(defun fac (n) (if (equalp n 1) 1 (* n (fac (1- n)))))
(format t \"fac of 7 is ~d~%\" (fac 7)))"
- (let ((body (rest (drop-while body (complement (partial #'string= '!L))))))
+ (let ((body (rest (drop-while body (lambda (x) (or (listp x)
+ (numberp x)
+ (not (string= x '!L))))))))
(if body
`(progn
,(first body)
diff --git a/test/tests.lisp b/test/tests.lisp
index 6f8a048..ffcfc78 100644
--- a/test/tests.lisp
+++ b/test/tests.lisp
@@ -1,6 +1,7 @@
(defpackage murja.tests
(:use :cl :fiveam)
(:import-from :murja.users.user-db :register-user)
+ (:import-from :murja.tests.literal :literal)
(:export :main-suite))
(in-package :murja.tests)
@@ -51,27 +52,42 @@
(is (equalp successfully-migrated t))))
(def-test history (:fixture prepare-db-and-server)
- (let ((posts (coerce (postmodern:query "SELECT * FROM blog.Post") 'list)))
- (is (not posts)))
-
- (let* ((user-id (register-user "test-user" "Test User" "" "passu"))
- (post-id (caar (murja.posts.post-db:insert-post "Test title" "new post" user-id "[]" t t)))
- (history-data (coerce (postmodern:query "SELECT * FROM blog.Post_History") 'list)))
- (is (not history-data))
- (murja.posts.post-db:update-post "New title" "New Content" "[]" t t post-id)
- (murja.posts.post-db:update-post "Newest title" "Newes Content" "[]" t t post-id)
- (murja.posts.post-db:update-post "Newest title" "Newes Content" "['test-tag']" nil nil post-id)
-
- (let ((post-data (postmodern:query "SELECT * FROM blog.Post" :array-hash))
- (history-data (coerce (postmodern:query "SELECT * FROM blog.Post_History" :array-hash) 'list))
- (count-of-hidden-history-entries 0))
-
- (dolist (hist history-data)
- (when (gethash "hidden" hist)
- (incf count-of-hidden-history-entries)))
-
- (is (equalp 2
- count-of-hidden-history-entries)))))
+ (literal
+ We are interested in seeing if the hidden? and unlisted? flags move correctly thorugh Lisp -> blog.Post -> blog.Post_History.
+
+ First lets see if the blog.Post and blog.Post_History tables are empty and we are in a sane initial state.
+
+ !L
+ (let ((posts (coerce (postmodern:query "SELECT * FROM blog.Post") 'list))
+
+ (history-data (postmodern:query "SELECT * FROM blog.Post_History")))
+ (is (not posts))
+ (is (not history-data)))
+
+ if that passes we need a test-user that posts content (othis should maybe be moved to a fixture "...") Using this new users ID we can post a new post that is initially both hidden AND unlisted.
+
+ !L
+ (let* ((user-id (register-user "test-user" "Test User" "" "passu"))
+ (post-id (caar (murja.posts.post-db:insert-post "Test title" "new post" user-id "[]" t t))))
+
+ (literal
+ Updating the post moves the initial version into the history table (amount of hidden posts 1)
+ !L
+ (murja.posts.post-db:update-post "New title" "New Content" "[]" t t post-id)
+
+ Now there is supposed to be 2 hidden posts
+ !L
+ (murja.posts.post-db:update-post "Newest title" "Newes Content" "[]" t t post-id)
+
+ Now there is supposed to be 3 hidden posts and the post in blog.Post is visible
+
+ !L
+ (murja.posts.post-db:update-post "Newester title" "Newes Content" "[\"test-tag\"]" nil nil post-id)
+
+ !L
+ (let ((history-data (coerce (postmodern:query "SELECT * FROM blog.Post_History where hidden" :array-hash) 'list)))
+ (is (equalp 3
+ (length history-data))))))))
;; (setf fiveam:*run-test-when-defined* t)