Skip to content

Commit

Permalink
Pass DataStore to logging reporter
Browse files Browse the repository at this point in the history
Fixes #86
  • Loading branch information
danielcompton committed Oct 30, 2015
1 parent 7a4428a commit bd9efa1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ragtime.core/src/ragtime/repl.clj
Expand Up @@ -12,7 +12,7 @@

(defn default-reporter
"A reporter function that just prints the migration ID to STDOUT."
[op id]
[_ op id]
(case op
:up (println "Applying" id)
:down (println "Rolling back" id)))
Expand All @@ -25,10 +25,10 @@
(reify p/Migration
(id [_] id)
(run-up! [_ store]
(reporter :up id)
(reporter store :up id)
(p/run-up! migration store))
(run-down! [_ store]
(reporter :down id)
(reporter store :down id)
(p/run-down! migration store)))))

(defn migrate
Expand Down
8 changes: 6 additions & 2 deletions ragtime.core/test/ragtime/repl_test.clj
Expand Up @@ -38,7 +38,11 @@

(deftest test-custom-reporter
(let [database (in-memory-db)
config {:datastore database :migrations migrations :reporter prn}]
config {:datastore database
:migrations migrations
:reporter (fn [ds op id] (prn (type ds) op id))}]
(is (= @(:data database) {:migrations #{}}))
(is (= (with-out-str (repl/migrate config))
":up \"a\"\n:up \"b\"\n:up \"c\"\n"))))
(str "ragtime.core_test.InMemoryDB :up \"a\"\n"
"ragtime.core_test.InMemoryDB :up \"b\"\n"
"ragtime.core_test.InMemoryDB :up \"c\"\n")))))

0 comments on commit bd9efa1

Please sign in to comment.