Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Commit

Permalink
added a test-env? function to util which is used in the main bot/init…
Browse files Browse the repository at this point in the history
… function. If an you set a system prop or env-var called ENVIRONMENT to TEST it will not init the threads for jarvis
  • Loading branch information
Jonathan Chauncey committed Feb 7, 2014
1 parent d1eddd9 commit a4afc25
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject com.rallydev/jarvis-core "1.5.3"
(defproject com.rallydev/jarvis-core "1.6.0"
:description "A robot for FlowDock"
:url "http://github.com/RallySoftware/jarvis-core"
:license {:name "The MIT License (MIT)"
Expand Down
2 changes: 1 addition & 1 deletion src/main/clojure/jarvis/bot.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
(log/info "Starting Jarvis...")
(when-let [plugins (plugins/load-plugins)]
(log/info "Starting to read from flowdock streams")
(init-threads plugins)))
(if-not (util/test-env?) (init-threads plugins))))

(defn -main []
(jarvis/init))
Expand Down
5 changes: 4 additions & 1 deletion src/main/clojure/jarvis/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@
(get "content")
(subs 1)
build-string
(edn/read-string)))))
(edn/read-string)))))

(defn test-env? []
(= "TEST" (config-property "ENVIRONMENT" false)))
7 changes: 6 additions & 1 deletion src/test/clojure/jarvis/util_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
(deftest message-content->vec
(is (= ["foo"] (util/message-content->vec {"content" "~foo"})))
(is (= ["foo" "bar"] (util/message-content->vec {"content" "~foo bar"})))
(is (= ["foo" "bar" "1"] (util/message-content->vec {"content" "~foo bar 1"}))))
(is (= ["foo" "bar" "1"] (util/message-content->vec {"content" "~foo bar 1"}))))

(deftest test-env
(is (= false (util/test-env?)))
(System/setProperty "ENVIRONMENT" "TEST")
(is (= true (util/test-env?))))

0 comments on commit a4afc25

Please sign in to comment.