Skip to content

Commit

Permalink
[#200] Filter out events related to Folders
Browse files Browse the repository at this point in the history
* Fixes the typo in spec definition
  • Loading branch information
iperdomo committed Feb 3, 2020
1 parent 5d549da commit c1d4f75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 1 addition & 9 deletions api/src/clojure/org/akvo/flow_api/unilog/spec.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(s/def ::surveyId ::id)
(s/def ::identifier string?)
(s/def ::name string?)
(s/def ::suveyGroupType #{"SURVEY"})
(s/def ::surveyGroupType #{"SURVEY"})

(s/def ::formInstance
(s/keys :req-un [::id ::formId]))
Expand Down Expand Up @@ -60,11 +60,3 @@
(s/valid?
spec
(-> m :payload :entity)))))

(comment
(gen/sample (s/gen ::event))

(valid? {:id 1
:payload {:eventType "answerCreated"
:entity {:formId 2
:formInstanceId 2}}}))
14 changes: 14 additions & 0 deletions api/test/clojure/org/akvo/flow_api/sync.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns org.akvo.flow-api.sync
(:require [clojure.test :refer :all]
[org.akvo.flow-api.unilog.unilog :as unilog]
[org.akvo.flow-api.unilog.spec :as spec]
[cheshire.core :as json]))

(def unilog-id-seq (atom 0))
Expand Down Expand Up @@ -79,6 +80,19 @@
(def survey-changes (comp :survey-changed changes-with-permissions))
(def survey-deleted (comp :survey-deleted changes-with-permissions))

(deftest event-spec
(testing "Basic event validation"
(is (true? (spec/valid? {:id 2
:payload {:eventType "surveyGroupUpdated"
:entity {:id 123
:name "Testing"
:surveyGroupType "SURVEY"}}})))
(is (false? (spec/valid? {:id 3
:payload {:eventType "surveyGroupUpdated"
:entity {:id 456
:name "Testing"
:surveyGroupType "FOLDER"}}})))))

(deftest unilog-batch
(testing "basic case"
(is (= #{{:form 24 :form-instance-ids #{2 10}}}
Expand Down

0 comments on commit c1d4f75

Please # to comment.