From a110c7397891a4e0b0ed82b20459064c718b3b3f Mon Sep 17 00:00:00 2001 From: Clemens Date: Tue, 18 Jul 2023 08:30:09 +0200 Subject: [PATCH] Added id-test --- .../activity_pub_poc/activitystreams2.clj | 5 ++--- .../activity_pub_poc/xsd.clj | 7 +++++++ .../activitystreams2_test.clj | 20 +++++++++++++------ 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/xsd.clj 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 b93acb8..d53aa2e 100644 --- a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.clj +++ b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.clj @@ -30,8 +30,7 @@ :uri core/uri-string? :map (s/and (s/keys :req-un [::id ::type] - :opt-un [::attributedTo ::und-mehr]) - (match-type "Object")))) + :opt-un [::attributedTo ::content ::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! @@ -59,7 +58,7 @@ ; #### NOTE #### ; Specialities of mastodon statuses: https://docs.joinmastodon.org/spec/activitypub/#status (s/def ::Note (s/and ::Object - (match-type "Note") + ;(match-type "Note") (s/keys :opt-un [::likes]))) diff --git a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/xsd.clj b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/xsd.clj new file mode 100644 index 0000000..abbad0e --- /dev/null +++ b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/xsd.clj @@ -0,0 +1,7 @@ +(ns org.domaindrivenarchitecture.activity-pub-poc.xsd + (:require [clojure.spec.alpha :as s])) + +; http://www.datypic.com/sc/xsd/t-xsd_anyURI.html +; TODO: Find out correct definition! +(defn anyUri? [input] + false) \ No newline at end of file diff --git a/src/test/clj/org/domaindrivenarchitecture/activitystreams2_test.clj b/src/test/clj/org/domaindrivenarchitecture/activitystreams2_test.clj index 8565ceb..cbedaec 100644 --- a/src/test/clj/org/domaindrivenarchitecture/activitystreams2_test.clj +++ b/src/test/clj/org/domaindrivenarchitecture/activitystreams2_test.clj @@ -5,9 +5,17 @@ [clojure.spec.alpha :as s] [org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 :as sut])) -(deftest Note-test - (is (s/valid? - ::sut/Note - {:id "https://social.bla/alyssa/status/RANDOMHASH" - :type "Note" - :content "text"}))) \ No newline at end of file +(deftest id-test + (is (s/valid? ::sut/id "https://social.bla/alyssa/status/RANDOMHASH"))) + + + + + + +;(deftest Note-test +; (is (s/valid? +; ::sut/Note +; {:id "https://social.bla/alyssa/status/RANDOMHASH" +; :type "Note" +; :content "text"})))