Skip to content

Commit

Permalink
Add empty statement store test
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinqian00 committed Aug 27, 2024
1 parent 891fdd9 commit 5972539
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/test/com/yetanalytics/lrs_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,25 @@
lrs/authorize
lrs/authorize-async])

(def auth-id
{:auth {:no-op {}}
:prefix ""
:scopes #{:scope/all}
:agent {"mbox" "mailto:[email protected]"}})

(deftest empty-store-test
(let [lrs (doto (mem/new-lrs {:statements-result-max 100})
(lrs/store-statements auth-id [] []))
ret-statements (get-in (lrs/get-statements lrs
auth-id
{:limit 100}
#{"en-US"})
[:statement-result :statements])]
(is (s/valid? ::xs/statements ret-statements))
(is (empty? ret-statements))))

(deftest query-test
(let [auth-id {:auth {:no-op {}}
:prefix ""
:scopes #{:scope/all}
:agent {"mbox" "mailto:[email protected]"}}
;; The serialized state shouldn't be used for this, because we're
(let [;; The serialized state shouldn't be used for this, because we're
;; changing things around.
;; The datasim data is not currently normalized, but only happens at a
;; max precision of 1 ms. That's timestamps though, looks like we have
Expand All @@ -75,8 +88,7 @@
[:statement-result :statements]))
ret-statements (get-ss {:limit 100})]
(testing (format "%s valid return statements?" (count ret-statements))
(is (s/valid? (s/every ::xs/statement)
ret-statements)))
(is (s/valid? ::xs/statements ret-statements)))
(testing "preserved?"
(is (= (dissoc (first ret-statements)
"authority"
Expand Down

0 comments on commit 5972539

Please sign in to comment.