summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2018-03-17 13:14:53 -0700
committerBen Sima <ben@bsima.me>2018-03-17 13:14:53 -0700
commit66e6b47737a9e6411f430a5cd169315f04dcd078 (patch)
tree15ebb5ba14f22c52faf487a7a4bdcb7e54cf332e
parentb48cd6640e4029b91d63c4f6a1843f953d4ff673 (diff)
Add reify health from yesterday
-rw-r--r--reify-health/.gitignore10
-rw-r--r--reify-health/README.md19
-rw-r--r--reify-health/project.clj12
-rw-r--r--reify-health/shell.nix18
-rw-r--r--reify-health/src/reify/handler.clj11
-rw-r--r--reify-health/test/reify/handler_test.clj14
6 files changed, 84 insertions, 0 deletions
diff --git a/reify-health/.gitignore b/reify-health/.gitignore
new file mode 100644
index 0000000..22d6a48
--- /dev/null
+++ b/reify-health/.gitignore
@@ -0,0 +1,10 @@
+/target
+/lib
+/classes
+/checkouts
+pom.xml
+pom.xml.asc
+*.jar
+*.class
+/.lein-*
+/.nrepl-port
diff --git a/reify-health/README.md b/reify-health/README.md
new file mode 100644
index 0000000..4042924
--- /dev/null
+++ b/reify-health/README.md
@@ -0,0 +1,19 @@
+# reify
+
+FIXME
+
+## Prerequisites
+
+You will need [Leiningen][] 2.0.0 or above installed.
+
+[leiningen]: https://github.com/technomancy/leiningen
+
+## Running
+
+To start a web server for the application, run:
+
+ lein ring server
+
+## License
+
+Copyright © 2018 FIXME
diff --git a/reify-health/project.clj b/reify-health/project.clj
new file mode 100644
index 0000000..2dcb252
--- /dev/null
+++ b/reify-health/project.clj
@@ -0,0 +1,12 @@
+(defproject reify "0.1.0-SNAPSHOT"
+ :description "FIXME: write description"
+ :url "http://example.com/FIXME"
+ :min-lein-version "2.0.0"
+ :dependencies [[org.clojure/clojure "1.8.0"]
+ [compojure "1.5.1"]
+ [ring/ring-defaults "0.2.1"]]
+ :plugins [[lein-ring "0.9.7"]]
+ :ring {:handler reify.handler/app}
+ :profiles
+ {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
+ [ring/ring-mock "0.3.0"]]}})
diff --git a/reify-health/shell.nix b/reify-health/shell.nix
new file mode 100644
index 0000000..7331059
--- /dev/null
+++ b/reify-health/shell.nix
@@ -0,0 +1,18 @@
+with import <nixpkgs> {};
+
+{
+ dm-datastream = pkgs.stdenv.mkDerivation rec {
+ name = "ReifyHealth-interview";
+ src = ./.;
+
+ buildInputs = [
+ leiningen
+ openjdk
+ ];
+
+ # lein complains without this:
+ shellHook = ''
+ unset CLASSPATH;
+ '';
+ };
+}
diff --git a/reify-health/src/reify/handler.clj b/reify-health/src/reify/handler.clj
new file mode 100644
index 0000000..b6c6683
--- /dev/null
+++ b/reify-health/src/reify/handler.clj
@@ -0,0 +1,11 @@
+(ns reify.handler
+ (:require [compojure.core :refer :all]
+ [compojure.route :as route]
+ [ring.middleware.defaults :refer [wrap-defaults site-defaults]]))
+
+(defroutes app-routes
+ (GET "/" [] "Hello World!!")
+ (route/not-found "Not Found"))
+
+(def app
+ (wrap-defaults app-routes site-defaults))
diff --git a/reify-health/test/reify/handler_test.clj b/reify-health/test/reify/handler_test.clj
new file mode 100644
index 0000000..450d544
--- /dev/null
+++ b/reify-health/test/reify/handler_test.clj
@@ -0,0 +1,14 @@
+(ns reify.handler-test
+ (:require [clojure.test :refer :all]
+ [ring.mock.request :as mock]
+ [reify.handler :refer :all]))
+
+(deftest test-app
+ (testing "main route"
+ (let [response (app (mock/request :get "/"))]
+ (is (= (:status response) 200))
+ (is (= (:body response) "Hello World"))))
+
+ (testing "not-found route"
+ (let [response (app (mock/request :get "/invalid"))]
+ (is (= (:status response) 404)))))