-- working :once and :each fixtures for login_test.clj
[bkell-clj.git] / test / login_test.clj
blob7fc13859e8116faecd37481d9e214be938c02c57
1 (ns login-test
3         ;;(:use [helpers] :reload-all)
4         ;;(:use [depth_adapter])
5         ;;(:require [bkell])
7     ;;(:use [clojure.test])
8         ;;(:import java.io.ByteArrayInputStream)
9         ;;(:require clojure.contrib.str-utils)
10     ;;(:require commands.add)
13 (use 'helpers )
14 (use 'depth_adapter)
15 (require 'bkell)
17 (use 'clojure.test)
18 (import 'java.io.ByteArrayInputStream)
19 (require 'clojure.contrib.str-utils)
20 (require 'commands.add)
22 (def configs (load-file "etc/config/config.test.clj"))
25 ;; FIXTUREs
26 (defn test-fixture-shell
27     "Initialize the shell"
28     [test]
30     (println "test-fixture-shell CALLED")
31     (bkell/init-shell)
33     (test)
35 (defn test-fixture-db
36     "test to clear out shell memory before a test is run"
37     [test]
39     (println "test-fixture-db CALLED")
40     ;; make the shell active
41         (dosync
42                 (alter bkell/shell conj
43                         { :active true }))
45     ;; create a basic user in the DB
46     (add-user (:url-test configs) (:system-dir configs) { :tag "user" :attrs { :id "test.user" } } )
48     ;; ** execute the TEST function
49     (test)
51     ;; make the shell inactive
52         (dosync
53                 (alter bkell/shell conj
54                         { :active false }))
58 (use-fixtures :once login-test/test-fixture-shell )
59 (use-fixtures :each login-test/test-fixture-db )
61 ;; test basic login
62 (deftest test-login []
64     (is (= 5 5))
68 ;; test result when already logged in
69 (deftest test-existing-login []
71     (is (= 5 5))
75 ;; test a login with a bad password
76 (deftest test-bad-password []
78     (is (= 5 5))
82 ;; test logging out
83 (deftest test-logout []
85     (is (= 5 5))