Skip to content

Commit

Permalink
added cleanup of temporary files from test
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoduncan committed Apr 18, 2010
1 parent 0027414 commit 4f9029b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/pallet/utils.clj
Expand Up @@ -208,6 +208,7 @@
(info (script-result :out)) (info (script-result :out))
(do (do
(error (str "Exit status " (script-result :exit))) (error (str "Exit status " (script-result :exit)))
(error (script-result :out))
(error (script-result :err)))) (error (script-result :err))))
(ssh session (str "rm " tmpfile)) (ssh session (str "rm " tmpfile))
(doseq [[file remote-name] *file-transfers*] (doseq [[file remote-name] *file-transfers*]
Expand Down
29 changes: 18 additions & 11 deletions test/pallet/resource/remote_file_test.clj
Expand Up @@ -7,6 +7,7 @@
(:require (:require
pallet.compat pallet.compat
[pallet.core :as core] [pallet.core :as core]
[pallet.resource.exec-script :as exec-script]
[pallet.compute :as compute] [pallet.compute :as compute]
[pallet.utils :as utils])) [pallet.utils :as utils]))


Expand Down Expand Up @@ -59,14 +60,20 @@


(with-temporary [tmp (tmpfile) (with-temporary [tmp (tmpfile)
target-tmp (tmpfile)] target-tmp (tmpfile)]
(.delete target-tmp) ;; this is convoluted to get around the "t" sticky bit on temp dirs
(io/copy "text" tmp) (let [user (assoc utils/*admin-user* :username (test-username) :no-sudo true)]
(core/defnode tag []) (.delete target-tmp)
(core/apply-phases-to-node (io/copy "text" tmp)
nil (compute/make-unmanaged-node "tag" "localhost") (core/defnode tag [])
[(phase (core/apply-phases-to-node
(remote-file (.getPath target-tmp) :local-file (.getPath tmp) nil (compute/make-unmanaged-node "tag" "localhost")
:owner (. System getProperty "user.name")))] [(phase
(assoc utils/*admin-user* :username (test-username) :no-sudo true)) (remote-file (.getPath target-tmp) :local-file (.getPath tmp) :mode "0666"))]
(is (.canRead target-tmp)) user)
(is (= "text" (slurp (.getPath target-tmp)))))) (is (.canRead target-tmp))
(is (= "text" (slurp (.getPath target-tmp))))
(core/apply-phases-to-node
nil (compute/make-unmanaged-node "tag" "localhost")
[(phase (exec-script/exec-script (script (rm ~(.getPath target-tmp)))))]
user)
(is (not (.exists target-tmp))))))

0 comments on commit 4f9029b

Please sign in to comment.