From d4747a6a0a38f74a406329b45f2d63d9c75afcd8 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Tue, 27 Aug 2024 10:39:52 -0400 Subject: [PATCH 1/4] Allow empty statement batches --- src/xapi_schema/spec.cljc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/xapi_schema/spec.cljc b/src/xapi_schema/spec.cljc index 1fd996e..43baf15 100644 --- a/src/xapi_schema/spec.cljc +++ b/src/xapi_schema/spec.cljc @@ -1326,8 +1326,13 @@ (some-> s :statement/object :statement-ref/objectType) true))))) +;; Statement batches in general, e.g. when being inserted into an LRS, should +;; allow empty arrays. + +;; Statement batches being retrieved from an LRS should always be non-emtpy. + (s/def ::statements - (s/coll-of ::statement :into [] :min-count 1)) + (s/coll-of ::statement :into [])) (s/def ::lrs-statements (s/coll-of ::lrs-statement :into [] :min-count 1)) From 4935036f1c7609f6a274b0d148a625af0b3ef67f Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Tue, 27 Aug 2024 10:45:10 -0400 Subject: [PATCH 2/4] Add test cases for statement batches --- test/xapi_schema/spec_test.cljc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/xapi_schema/spec_test.cljc b/test/xapi_schema/spec_test.cljc index 3bb546d..9b4e306 100644 --- a/test/xapi_schema/spec_test.cljc +++ b/test/xapi_schema/spec_test.cljc @@ -626,3 +626,16 @@ "verb" {"id" "http://adlnet.gov/expapi/verbs/voided" "display" {"en-US" "voided"}} "object" {"id" "http://example.com/activities/1"}}))) + +(deftest statements-test + (testing "generic statememt batch" + (should-satisfy+ ::xs/statements + [simple-statement] + [simple-statement long-statement] + [])) + (testing "LRS retrieval statement batch" + (should-satisfy+ ::xs/lrs-statements + [simple-statement] + [simple-statement long-statement] + :bad + []))) From 6f01e8d8e274d2e74092b032522a39545f940f52 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Tue, 27 Aug 2024 10:52:41 -0400 Subject: [PATCH 3/4] Use valid statement in lrs-statements test --- test/xapi_schema/spec_test.cljc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/xapi_schema/spec_test.cljc b/test/xapi_schema/spec_test.cljc index 9b4e306..906527b 100644 --- a/test/xapi_schema/spec_test.cljc +++ b/test/xapi_schema/spec_test.cljc @@ -635,7 +635,6 @@ [])) (testing "LRS retrieval statement batch" (should-satisfy+ ::xs/lrs-statements - [simple-statement] - [simple-statement long-statement] + [d/statement] ; This statement has ID and other required fields :bad []))) From 63614c73224ecb54843177ce8878a32fc9cabc50 Mon Sep 17 00:00:00 2001 From: kelvinqian00 Date: Tue, 27 Aug 2024 10:59:44 -0400 Subject: [PATCH 4/4] Allow empty lrs-statements anyways --- src/xapi_schema/spec.cljc | 7 +------ test/xapi_schema/spec_test.cljc | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/xapi_schema/spec.cljc b/src/xapi_schema/spec.cljc index 43baf15..05c351f 100644 --- a/src/xapi_schema/spec.cljc +++ b/src/xapi_schema/spec.cljc @@ -1326,13 +1326,8 @@ (some-> s :statement/object :statement-ref/objectType) true))))) -;; Statement batches in general, e.g. when being inserted into an LRS, should -;; allow empty arrays. - -;; Statement batches being retrieved from an LRS should always be non-emtpy. - (s/def ::statements (s/coll-of ::statement :into [])) (s/def ::lrs-statements - (s/coll-of ::lrs-statement :into [] :min-count 1)) + (s/coll-of ::lrs-statement :into [])) diff --git a/test/xapi_schema/spec_test.cljc b/test/xapi_schema/spec_test.cljc index 906527b..b7d6e12 100644 --- a/test/xapi_schema/spec_test.cljc +++ b/test/xapi_schema/spec_test.cljc @@ -636,5 +636,4 @@ (testing "LRS retrieval statement batch" (should-satisfy+ ::xs/lrs-statements [d/statement] ; This statement has ID and other required fields - :bad [])))