From 84ae5642bb24e65b5193472cda94977e16002145 Mon Sep 17 00:00:00 2001 From: Mirco Date: Fri, 21 Jul 2023 17:43:10 +0200 Subject: [PATCH] Add Link as Object Type to spec; add object-test and link-test to activitystreams2_test --- .gitignore | 3 ++- .../activity_pub_poc/activitystreams2.clj | 4 +++- .../activitystreams2_test.clj | 11 +++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d6b19a9..a5b76ef 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ pom.xml.asc .clj-kondo/.cache/ .clj-kondo/metosin/ .lsp/.cache/ -.calva \ No newline at end of file +.calva +.idea \ No newline at end of file diff --git a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.clj b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.clj index d53aa2e..17ac843 100644 --- a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.clj +++ b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.clj @@ -19,6 +19,7 @@ "Relationship" "Tombstone" "Video" + "Link" ; Link Types "Mention"}) @@ -30,7 +31,8 @@ :uri core/uri-string? :map (s/and (s/keys :req-un [::id ::type] - :opt-un [::attributedTo ::content ::und-mehr])))) + :opt-un [::attributedTo ::und-mehr])))) + (s/def ::id core/uri-string?) ; TODO: type can have multiple values!! Affects also the fct match-type and all specs that uses it! diff --git a/src/test/clj/org/domaindrivenarchitecture/activitystreams2_test.clj b/src/test/clj/org/domaindrivenarchitecture/activitystreams2_test.clj index cbedaec..59b6738 100644 --- a/src/test/clj/org/domaindrivenarchitecture/activitystreams2_test.clj +++ b/src/test/clj/org/domaindrivenarchitecture/activitystreams2_test.clj @@ -8,10 +8,17 @@ (deftest id-test (is (s/valid? ::sut/id "https://social.bla/alyssa/status/RANDOMHASH"))) +(deftest type-test + (is (s/valid? ::sut/type "Note")) + (is (s/valid? ::sut/type "Link")) + (is (not(s/valid? ::sut/type "non existing")))) +(deftest object-test + (is (s/valid? ::sut/Object "https://social.bla/alyssa/status/RANDOMHASH") + (is (s/valid? ::sut/Object {:id "https://social.bla/alyssa/status/RANDOMHASH" :type "Page"})))) - - +(deftest link-test + (is (s/valid? ::sut/Link {:type "Link"}))) ;(deftest Note-test ; (is (s/valid?