Put sources in src/clj[s], tests in test/clj[s]

This commit is contained in:
Nicholas Kariniemi 2013-08-17 14:28:46 +03:00
parent 08f726b963
commit 9943a58fd7
14 changed files with 25 additions and 31 deletions

View file

@ -3,7 +3,8 @@
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:source-paths ["src-clj"]
:source-paths ["src/clj"]
:test-paths ["test/clj"]
:dependencies [[org.clojure/clojure "1.5.1"]
[http-kit "2.1.8"]
[compojure "1.1.5"]
@ -19,7 +20,7 @@
:cljsbuild {
:builds [{
; The path to the top-level ClojureScript source directory:
:source-paths ["src-cljs"]
:source-paths ["src/cljs"]
; The standard ClojureScript compiler options:
; (See the ClojureScript compiler documentation for details.)
:compiler {

View file

@ -32,7 +32,7 @@
(def app
(let [dev? true]
(if dev?
(reload/wrap-reload (handler/site #'routes) {:dirs ["src-clj"]})
(reload/wrap-reload (handler/site #'routes) {:dirs ["src/clj"]})
(handler/site routes))))
(defn -main [& args]

View file

@ -25,7 +25,7 @@
(defn push-received-events-to-client [c ws-channel]
(go-loop (let [event (<! c)
event-str (str event)]
(println "Send to client" event)
(println "Send to client" event-str)
(httpkit/send! ws-channel event-str))))
(defn add-incoming-event [raw-event ws-channel-id]
@ -38,7 +38,7 @@
(let [[incoming incoming'] (fan-out incoming-events 2)]
(do-chan! push-event-to-others incoming)
(go-loop (let [event (<! incoming')]
(>! (db/get-incoming-events) event)))))
(>! @db/incoming-events event)))))
(defn websocket-handler [request]
(httpkit/with-channel request ws-channel

View file

@ -14,6 +14,7 @@
(defn get-remote-events []
(let [out (chan)]
(aset @websocket* "onmessage" (fn [event]
(logs "received event" event)
(let [grub-event (cljs.reader/read-string (.-data event))]
(logs "Received:" grub-event)
(go (>! out grub-event)))))

18
test/clj/grub/db_test.clj Normal file
View file

@ -0,0 +1,18 @@
(ns grub.db-test
(:require [midje.sweet :refer [fact with-state-changes contains anything]]
[monger.collection :as mc]
[grub.db :as db]
[clojure.core.async :refer [>!!]]))
(def test-db "grub-test")
(with-state-changes [(before :facts (do (db/connect-and-handle-events test-db)
(mc/drop db/grub-collection)))]
(fact
"Add grub"
(fact "sending an event creates a grub"
(let [test-grub "testgrub"
test-id 12345]
(>!! @db/incoming-events {:event :create :_id test-id :grub test-grub})
(mc/find-one-as-map db/grub-collection {:_id test-id}) =>
{:_id test-id :grub test-grub :completed false}))))

View file

@ -1,26 +0,0 @@
(ns grub.db-test
(:require [midje.sweet :refer [fact with-state-changes contains anything]]
[monger.collection :as mc]
[grub.db :as db]
[clojure.core.async :refer [>!!]]))
(def test-db "grub-test")
(with-state-changes [(before :facts (do (mc/drop db/grub-collection)
(db/connect-and-handle-events test-db)))]
(fact
"Add grub"
(fact "sending an event creates a grub"
(let [test-grub "testgrub"
test-id 12345]
(>!! @db/incoming-events {:event :create :_id test-id :grub test-grub})
(mc/find-one-as-map db/grub-collection {:_id test-id}) =>
{:_id test-id :grub test-grub :completed false}))
(fact "missing an id means grub is not created"
(>!! @db/incoming-events {:event :create :grub "testgrub"})
(mc/find-maps db/grub-collection) =>
empty?)
(fact "missing grub text means grub is not created"
(>!! @db/incoming-events {:event :create :_id 12345})
(mc/find-maps db/grub-collection) =>
empty?)))