Skip to content

Instantly share code, notes, and snippets.

@cddr
Created February 23, 2016 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cddr/bf9da9c662a205dea0b3 to your computer and use it in GitHub Desktop.
Save cddr/bf9da9c662a205dea0b3 to your computer and use it in GitHub Desktop.
(defn run-test-job
"Runs the email job for `timeout` milliseconds before returning whatever
has been accumulated in `sent-emails`.
TODO: Consider promoting more generic version of this to samza-config"
[timeout]
(let [job (MapConfig. (assoc (into {} (find-job 'notifications-handler.core.email))
"job.task.send-fn" (full-name 'mock-send-fn)))]
(let [job-proc (.run (JobRunner. job) true)]
(s/stream->seq sent-emails timeout))))
(deftest send-some-emails
(with-uuids [id tracking-id]
(let-flow [result (run-test-job 2000)]
(let [msg {:id id
:tracking-id tracking-id
:to "achambers.home@gmail.com"
:from "engineering@fundingcircle.com"
:subject "yolo"
:body ""
:published-at 0
:published-by "test"}]
(println "sending email one")
(send-email msg)
(println "sending email two")
(send-email msg))
(when (= result :timeout)
(is false "Timed out waiting for test email job"))
(is (= 1 (count result)))
(is (= {:tracking-id tracking-id
:to "achambers.home@gmail.com"
:from "engineering@fundingcircle.com"
:subject "yolo"
:body ""}
(select-keys (first result)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment