Browse Source

Added coverage for validation errors

master
Stephen Starkey 2 years ago
parent
commit
a135dd1577
  1. 15
      test/clj/email_counter/test/handler.clj

15
test/clj/email_counter/test/handler.clj

@ -63,12 +63,21 @@
"scstarkey@gmail.com"]))))
(testing "invalid email address"
(is (= {:status 400,
(is (= {:status 400
:body "{:emails [(not (EmailAddress \"busted\"))]}"}
(request-emails ["busted"]))))
(request-emails ["busted"])))
(is (= {:status 400
:body
(str "{:emails [(not (instance? java.lang.String 42)) "
"(not (EmailAddress \"\")) "
"(not (instance? java.lang.String nil)) "
"(not (instance? java.lang.String false)) "
"nil]}")}
(request-emails [42 "" nil false "me@here.com"]))))
(testing "invalid request"
(is (= {:status 400,
(is (= {:status 400
:body "{:emails missing-required-key, :test disallowed-key}"}
(post-body email-route {:test "stuff"}))))

Loading…
Cancel
Save