                        "status" "foo status 2 :info"}}
                body))))
     (testing "uses status level from query param"
-      (let [req (http-client/get "http://localhost:8180/status/v1/services?level=debug")
-            body (json/parse-string (slurp (:body req)))]
-        (is (= 200 (:status req)))
+      (let [resp (http-client/get "http://localhost:8180/status/v1/services?level=debug")
+            body (json/parse-string (slurp (:body resp)))]
+        (is (= 200 (:status resp)))
         (is (= {"bar" {"service-version" "0.1.0"
                        "service-status-version" 1
                        "status" "bar status 1 :debug"}

    [foo-service
     bar-service]
    (testing "returns latest status for all services"
      (let [req (http-client/get "http://localhost:8180/status/v1/services")
            body (json/parse-string (slurp (:body req)))]
        (is (= 200 (:status req)))
        (is (= {"bar" {"service-version" "0.1.0"
                       "service-status-version" 1
                       "status" "bar status 1 :info"}

    app
    [foo-service]
    (testing "returns service information for service that has registered a callback"
      (let [resp (http-client/get "http://localhost:8180/status/v1/services/foo")]
        (is (= 200 (:status resp)))
        (is (= {"service-version" "1.1.0"
                "service-status-version" 2
                "status" "foo status 2 :info"
                "service-name" "foo"}
               (json/parse-string (slurp (:body resp)))))))
    (testing "uses status level query param"
      (let [resp (http-client/get "http://localhost:8180/status/v1/services/foo?level=critical")]
        (is (= 200 (:status resp)))
        (is (= {"service-version" "1.1.0"
                "service-status-version" 2
                "status" "foo status 2 :critical"
                "service-name" "foo"}
               (json/parse-string (slurp (:body resp)))))))
    (testing "returns a 404 for service not registered with the status service"
      (let [resp (http-client/get "http://localhost:8180/status/v1/services/notfound")]
        (is (= 404 (:status resp)))
        (is (= {"error" {"type" "service-not-found"
                         "message" "No status information found for service notfound"}}
               (json/parse-string (slurp (:body resp)))))))))

(deftest error-handling-test
  (with-status-service app []
    (testing "returns a 400 when an invalid level is queried for"
      (let [resp (http-client/get "http://localhost:8180/status/v1/services?level=bar")]
        (is (= 400 (:status resp)))
        (is (= {"error" {"type" "request-data-invalid"
                         "message" "Invalid level: :bar"}}
               (json/parse-string (slurp (:body resp)))))))))
