commit 8445fbdeee63b0bc280e479363799634c61916e0
parent 6e7ab0dfdbe4f2de63925b6a3e27e73f29484fe6
Author: Decay <decaydjk@tilde.town>
Date: Tue, 13 Oct 2020 05:33:28 +0000
Fixing with-page-id/with-entry-id
Forgot to really properly update my tests! Let this be a lesson!
Diffstat:
2 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/src/data.lisp b/src/data.lisp
@@ -47,7 +47,7 @@
"Takes a varname to hold the entry list and a post id
and executes the forms in body with the entry bound
to the specified entry variable"
- `(let ((,entry (miniblog.db:get-entry ,id)))
+ `(let ((,entry (miniblog.data:get-entry ,id)))
(if ,entry
(progn ,@body)
(format t "Post ID ~d not found~%" ,id))))
@@ -77,7 +77,7 @@
"Takes a varname to hold the entry list and a page id
and executes the forms in body with the entry bound
to the specified entry variable"
- `(let ((,page (miniblog.db:get-page ,id)))
+ `(let ((,page (miniblog.data:get-page ,id)))
(if ,page
(progn ,@body)
(format t "Page ID ~d not found~%" ,id))))
diff --git a/tst/data.lisp b/tst/data.lisp
@@ -13,24 +13,24 @@
(username "test")
(new-entry (miniblog.data:add-entry title content :username username))
(now (local-time:now))
- (new-id (getf new-entry :id))
- (fetched-entry (miniblog.data:get-entry new-id)))
- (is (and (string= title (getf new-entry :title))
- (string= title (getf fetched-entry :title))))
- (is (and (string= content (getf new-entry :content))
- (string= content (getf fetched-entry :content))))
- (is (and (string= username (getf new-entry :created-by))
- (string= username (getf fetched-entry :created-by))))
- (is (and (string= username (getf new-entry :last-updated-by))
- (string= username (getf fetched-entry :last-updated-by))))
- (is (and (< (timestamp-difference now (getf new-entry :created-at)) 1)
- (>= (timestamp-difference now (getf new-entry :created-at)) 0)))
- (is (and (timestamp= (getf new-entry :created-at)
- (getf new-entry :last-updated-at))))
- (is (and (timestamp= (getf new-entry :created-at)
- (getf fetched-entry :created-at))))
- (is (and (timestamp= (getf new-entry :last-updated-at)
- (getf fetched-entry :last-updated-at)))))))
+ (new-id (getf new-entry :id)))
+ (miniblog.data:with-entry-id fetched-entry new-id
+ (is (and (string= title (getf new-entry :title))
+ (string= title (getf fetched-entry :title))))
+ (is (and (string= content (getf new-entry :content))
+ (string= content (getf fetched-entry :content))))
+ (is (and (string= username (getf new-entry :created-by))
+ (string= username (getf fetched-entry :created-by))))
+ (is (and (string= username (getf new-entry :last-updated-by))
+ (string= username (getf fetched-entry :last-updated-by))))
+ (is (and (< (timestamp-difference now (getf new-entry :created-at)) 1)
+ (>= (timestamp-difference now (getf new-entry :created-at)) 0)))
+ (is (and (timestamp= (getf new-entry :created-at)
+ (getf new-entry :last-updated-at))))
+ (is (and (timestamp= (getf new-entry :created-at)
+ (getf fetched-entry :created-at))))
+ (is (and (timestamp= (getf new-entry :last-updated-at)
+ (getf fetched-entry :last-updated-at))))))))
(test modify-entry
"Update an entry, verify update fields"
@@ -71,28 +71,28 @@
(username "test")
(new-page (miniblog.data:add-page name title content :username username))
(now (local-time:now))
- (new-id (getf new-page :id))
- (fetched-page (miniblog.data:get-page new-id)))
- (is (and (eql 0 (getf new-page :parent))
- (eql 0 (getf fetched-page :parent))))
- (is (and (string= name (getf new-page :name))
- (string= name (getf fetched-page :name))))
- (is (and (string= title (getf new-page :title))
- (string= title (getf fetched-page :title))))
- (is (and (string= content (getf new-page :content))
- (string= content (getf fetched-page :content))))
- (is (and (string= username (getf new-page :created-by))
- (string= username (getf fetched-page :created-by))))
- (is (and (string= username (getf new-page :last-updated-by))
- (string= username (getf fetched-page :last-updated-by))))
- (is (and (< (timestamp-difference now (getf new-page :created-at)) 1)
- (>= (timestamp-difference now (getf new-page :created-at)) 0)))
- (is (and (timestamp= (getf new-page :created-at)
- (getf new-page :last-updated-at))))
- (is (and (timestamp= (getf new-page :created-at)
- (getf fetched-page :created-at))))
- (is (and (timestamp= (getf new-page :last-updated-at)
- (getf fetched-page :last-updated-at)))))))
+ (new-id (getf new-page :id)))
+ (miniblog.data:with-page-id fetched-page new-id
+ (is (and (eql 0 (getf new-page :parent))
+ (eql 0 (getf fetched-page :parent))))
+ (is (and (string= name (getf new-page :name))
+ (string= name (getf fetched-page :name))))
+ (is (and (string= title (getf new-page :title))
+ (string= title (getf fetched-page :title))))
+ (is (and (string= content (getf new-page :content))
+ (string= content (getf fetched-page :content))))
+ (is (and (string= username (getf new-page :created-by))
+ (string= username (getf fetched-page :created-by))))
+ (is (and (string= username (getf new-page :last-updated-by))
+ (string= username (getf fetched-page :last-updated-by))))
+ (is (and (< (timestamp-difference now (getf new-page :created-at)) 1)
+ (>= (timestamp-difference now (getf new-page :created-at)) 0)))
+ (is (and (timestamp= (getf new-page :created-at)
+ (getf new-page :last-updated-at))))
+ (is (and (timestamp= (getf new-page :created-at)
+ (getf fetched-page :created-at))))
+ (is (and (timestamp= (getf new-page :last-updated-at)
+ (getf fetched-page :last-updated-at))))))))
(test modify-page
"Update a page, verify update fields"