Remove unused speclj tests

This commit is contained in:
Nicholas Kariniemi 2014-07-30 17:59:34 +03:00
parent 8cd03220d3
commit 2bb162d98a

View file

@ -1,84 +0,0 @@
(ns grub.db-spec
(:require [speclj.core :refer :all]
[grub.db :as db]
[monger.collection :as mc]
[clojure.core.async :refer [>!! <!! timeout]]))
(def test-db "grub-test")
(defn short-delay []
(<!! (timeout 50)))
(defn get-test-grub []
{:_id (str "grub" (rand-int 10000))
:grub (str "testtext" (rand-int 1000))
:completed ([true false] (rand-int 1))})
(describe
"grub.db"
(before-all (db/connect-and-handle-events test-db))
(before (db/clear-grubs))
(describe "Add"
(it "should add a grub when an add event comes"
(let [test-grub "testgrub"
test-id 12345]
(>!! @db/incoming-events {:event :add
:_id test-id
:grub test-grub
:completed false})
(short-delay)
(should=
{:_id test-id :grub test-grub :completed false}
(mc/find-one-as-map db/grub-collection {:_id test-id})))))
(describe "Complete"
(it "should complete a grub when a complete event comes"
(let [test-grub {:_id 123456 :completed false}]
(mc/insert db/grub-collection test-grub)
(>!! @db/incoming-events {:event :complete :_id (:_id test-grub)})
(short-delay)
(should=
{:_id (:_id test-grub) :completed true}
(mc/find-one-as-map db/grub-collection {:_id (:_id test-grub)})))))
(describe "Uncomplete"
(it "should uncomplete a grub when an uncomplete event comes"
(let [test-grub {:_id 123456 :completed true}]
(mc/insert db/grub-collection test-grub)
(>!! @db/incoming-events {:event :uncomplete :_id (:_id test-grub)})
(short-delay)
(should=
{:_id (:_id test-grub) :completed false}
(mc/find-one-as-map db/grub-collection {:_id (:_id test-grub)})))))
(describe "Update"
(it "should update grub info when an update event comes"
(let [test-grub {:_id 123456 :grub "original"}]
(mc/insert db/grub-collection test-grub)
(>!! @db/incoming-events {:event :update
:_id (:_id test-grub)
:grub "updated"})
(short-delay)
(should=
{:_id (:_id test-grub) :grub "updated"}
(mc/find-one-as-map db/grub-collection {:_id (:_id test-grub)})))))
(describe "Delete"
(it "should delete a grub when a delete event comes"
(let [test-grub {:_id 123456 :completed true}]
(mc/insert db/grub-collection test-grub)
(>!! @db/incoming-events {:event :delete :_id (:_id test-grub)})
(short-delay)
(should=
nil
(mc/find-one-as-map db/grub-collection {:_id (:_id test-grub)})))))
(describe "Clear all"
(it "should delete all grubs"
(let [test-grub {:_id 123456 :completed true}]
(mc/insert db/grub-collection test-grub)
(>!! @db/incoming-events {:event :clear-all})
(short-delay)
(should
(empty?
(mc/find-maps db/grub-collection)))))))