       (destroy-session mock-session)
       (is (not (contains? @memory-sessions ::mock-id))))))
 
+;; Session routes
+
 (deftest session-nil-response
   (let [handler  (with-session (constantly nil))
         response (handler {})]

(ns test.compojure.http.session
  (:use compojure.http.session)
  (:use clojure.contrib.test-is))

(deftest create-memory-session
  (binding [*session-store* :memory]


(defmethod write-session ::mock [session])

(defmethod read-session ::mock [id]
  (is (= id ::mock-id))
  {:id ::mock-id})

(defmethod session-cookie ::mock [new? session]
  "mock-session-cookie")

(defn- mock-session-response
  [request response]
  (let [handler (with-session (constantly response))]
    (handler request)))

(deftest new-session-cookie
  (binding [*session-store* ::mock]
    (let [response (mock-session-response {} {})]
      (is (= (get-in response [:headers "Set-Cookie"])
             "session=mock-session-cookie")))))

(deftest response-session-cookie
  (binding [*session-store* ::mock]
    (let [response (mock-session-response {} {:session {}})]
      (is (= (get-in response [:headers "Set-Cookie"])
             "session=mock-session-cookie")))))

(deftest session-store-test
