Starting to dogfood Facai a little more
(deftest contact-handler-test
(let [handler (:grid.contacts/list-contacts-handler sys/*system*)
user (sys/create! factories/user)
org-user (sys/create! factories/organization-user {:with {:user-id (:id user)}})]
(doseq [name ["a" "b" "c"]]
(let [contact (sys/create! factories/contact
{:with {:name name
:org-id (:organization-id org-user)
:created-by (:id user)}})]
(sys/create!
factories/email
{:with {:email (str name "@example.com")
:contact-id (:id contact)
:created-by (:id user)}})))
(is (match?
{:status 200
:body
(matchers/in-any-order
[{:name "a" :email ""}
{:name "b" :email ""}
{:name "c" :email ""}])}
(handler {:identity (:email user)}))))) Still some room to tidy that up but I think I like it.