Browse Source

Better schema naming

master
Stephen Starkey 2 years ago
parent
commit
0bccaa0d64
  1. 5
      src/clj/email_counter/routes/services.clj
  2. 4
      test/clj/email_counter/test/handler.clj

5
src/clj/email_counter/routes/services.clj

@ -15,7 +15,8 @@
(def NaturalNumber (s/constrained s/Int (complement neg?) 'NaturalNumber))
(def EmailAddress (s/constrained s/Str emails/parse-for-gmail 'EmailAddress))
(def GmailFriendlyAddress
(s/constrained s/Str emails/parse-for-gmail 'GmailFriendlyAddress))
(defn count-emails [{{{:keys [emails]} :body} :parameters}]
(ok {:total (emails/count-unique emails)}))
@ -53,6 +54,6 @@
"many unique email addresses show up, after "
"accounting for Gmail's unique approach to "
"parsing.")
:parameters {:body {:emails [EmailAddress]}}
:parameters {:body {:emails [GmailFriendlyAddress]}}
:responses {200 {:body {:total NaturalNumber}}}
:handler count-emails}}]]])

4
test/clj/email_counter/test/handler.clj

@ -64,13 +64,13 @@
(testing "invalid email address"
(is (= {:status 400
:body "{:emails [(not (EmailAddress \"busted\"))]}"}
:body "{:emails [(not (GmailFriendlyAddress \"busted\"))]}"}
(request-emails ["busted"])))
(is (= {:status 400
:body
(str "{:emails [(not (instance? java.lang.String 42)) "
"(not (EmailAddress \"\")) "
"(not (GmailFriendlyAddress \"\")) "
"(not (instance? java.lang.String nil)) "
"(not (instance? java.lang.String false)) "
"nil]}")}

Loading…
Cancel
Save