Created
August 30, 2011 19:48
-
-
Save paul/1181836 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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