Skip to content

Instantly share code, notes, and snippets.

@paul
Created August 30, 2011 19:48
Show Gist options
  • Save paul/1181836 to your computer and use it in GitHub Desktop.
Save paul/1181836 to your computer and use it in GitHub Desktop.
(ns seraph.test.redirect
(:use
clojure.test
picard.test
picard.helpers
seraph.redirect))
(defn handle-request
[{path-info :path-info :as hdrs} body]
(cond
(= "api.strobeapp.com" host))
[200 {:request-hdrs hdrs} "you got api.strobeapp.com"]
(= "api.strobeapp.local" host))
[200 {:request-hdrs hdrs} "you got api.strobeapp.local"]
:else
[404 {} ""]
(defn- mock-proxy
[dn]
(defstream
(request [[hdrs body]]
(dn :response (handle-request hdrs body)))))
(defmacro with-stack
[opts & stmts]
(if-not (map? opts)
`(with-stack {} ~opts ~@stmts)
`(with-app
(routing/mk-stack
{:api-proxy mock-proxy})
~@stmts)))
(deftest ^{:focus true} forwards-api-request-default
(with-stack
(GET "api.strobeapp.com/applications")
(is (= 200 (last-response-status)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment