Skip to content
Snippets Groups Projects
Commit 5d5a1c64 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

* add H2 database to the project dependencies

* create a simple place to store application wide default config settings
* configure our Korma db using app defaults or overridable environment variables
* tell git to ignore any locally defined leiningen profiles from profiles.clj
parent 8dab022c
No related branches found
No related tags found
No related merge requests found
......@@ -11,3 +11,4 @@ pom.xml.asc
.hg/
.idea/
/docs
profiles.clj
......@@ -13,6 +13,7 @@
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]
[com.h2database/h2 "1.3.170"] ; embedded SQL database
[korma "0.4.0"] ; SQL lib
]
:plugins [[cider/cider-nrepl "0.8.2"] ; Interactive development w/ cider NREPL in Emacs
......
(ns metabase.config)
(def app-defaults
"Global application defaults"
{:database-file "metabase.db"})
\ No newline at end of file
(ns metabase.db
(:require [clojure.tools.logging :as log]
[environ.core :refer [env]]
[korma.core :refer :all]
[korma.db :refer :all]
[metabase.config :refer [app-defaults]]))
(defn get-db-file
"Check config/environment to determine the path to the h2 db file we want to use"
[]
(or (env :database-file) (get app-defaults :database-file)))
(defdb db (do
(log/info (str "Using H2 database file: " (get-db-file)))
(h2 {:db (get-db-file)})))
(ns metabase.core-test
(:use midje.sweet)
(:use [metabase.core])
(:require [clojure.tools.logging :as log]))
(println "You should expect to see three failures below.")
(log/info "testing out this logging")
(facts "about `first-element`"
(fact "it normally returns the first element"
(first-element [1 2 3] :default) => 1
(first-element '(1 2 3) :default) => 1)
;; I'm a little unsure how Clojure types map onto the Lisp I'm used to.
(fact "default value is returned for empty sequences"
(first-element [] :default) => :default
(first-element '() :default) => :default
(first-element nil :default) => :default
(first-element (filter even? [1 3 5]) :default) => :default))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment