From 5047f12a493f4c8085fbd9d3dae281fddf0b0bc8 Mon Sep 17 00:00:00 2001 From: Timothy Washington Date: Mon, 4 Oct 2010 21:09:53 -0400 Subject: [PATCH] -- adding first real test to check logged-in-user -- putting 'login-test/test-fixture-shell' into the :each fixture -- putting login into a separate 'commands/authenticate.clj' file --- src/commands/authenticate.clj | 11 +++++++++++ src/depth_adapter.clj | 22 ++++++++++++---------- test/login_test.clj | 19 ++++++++++++++++--- 3 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 src/commands/authenticate.clj diff --git a/src/commands/authenticate.clj b/src/commands/authenticate.clj new file mode 100644 index 0000000..f61b493 --- /dev/null +++ b/src/commands/authenticate.clj @@ -0,0 +1,11 @@ +(require 'bkell) + +(defn login-user [user_seq] + + (dosync + (alter bkell/shell conj + { :logged-in-user user_seq } ) + (alter bkell/shell conj + { :previous user_seq })) +) + diff --git a/src/depth_adapter.clj b/src/depth_adapter.clj index fbba518..3abe14f 100644 --- a/src/depth_adapter.clj +++ b/src/depth_adapter.clj @@ -16,6 +16,7 @@ (:require xpath_handler) (:require commands.add) + (:require commands.authenticate) ) @@ -82,16 +83,17 @@ (.. node getCommandInput (apply this) ) ;; execute LOGIN - (operate-dep-inputtype node - (fn [result_seq] - - (dosync - (alter bkell/shell conj - { :logged-in-user result_seq } ) - (alter bkell/shell conj - { :previous result_seq })) - (println "DEBUG > logged-in-user > " ((deref bkell/shell) :logged-in-user)) - )) + (operate-dep-inputtype node + (fn [result_seq] + + (login-user result_seq) + (comment dosync + (alter bkell/shell conj + { :logged-in-user result_seq } ) + (alter bkell/shell conj + { :previous result_seq })) + (println "DEBUG > logged-in-user > " ((deref bkell/shell) :logged-in-user)) + )) ) ) diff --git a/test/login_test.clj b/test/login_test.clj index b40fcfa..9458647 100644 --- a/test/login_test.clj +++ b/test/login_test.clj @@ -9,6 +9,7 @@ (:require clojure.contrib.str-utils) (:require commands.add) (:require commands.remove) + (:require commands.authenticate) ) @@ -46,13 +47,25 @@ ) -(use-fixtures :once login-test/test-fixture-shell ) -(use-fixtures :each login-test/test-fixture-db ) +;;(use-fixtures :once login-test/test-fixture-shell ) +(use-fixtures :each login-test/test-fixture-shell login-test/test-fixture-db ) ;; test basic login (deftest test-login [] - (is (= 5 5)) + + (let [ + user_seq + (login-user (helpers/get-user (:url-test configs) (:system-dir configs) { :tag "user" :attrs { :id "test.user"}} )) ] + + (is (not (nil? user_seq)) + (str + "User should NOT be nil > inputs > " + (:url-test configs) " " (:system-dir configs) " " { :tag "user" :attrs { :id "test.user"}} ) + ) + (is (not (nil? (@bkell/shell :logged-in-user))) + "User should be in a 'logged-in-user' state") + ) ) -- 2.11.4.GIT