mirror of https://github.com/apache/jclouds.git
Added example test for compound predicates with and macro
This commit is contained in:
parent
cd87342800
commit
19672715e0
|
@ -22,8 +22,8 @@
|
|||
(:use clojure.test)
|
||||
(:import
|
||||
org.jclouds.compute.domain.OsFamily
|
||||
clojure.contrib.condition.Condition))
|
||||
|
||||
clojure.contrib.condition.Condition
|
||||
java.net.InetAddress))
|
||||
|
||||
(defmacro with-private-vars [[ns fns] & tests]
|
||||
"Refers private fns from ns and runs tests in context. From users mailing
|
||||
|
@ -75,6 +75,17 @@ list, Alan Dipert and MeikelBrandmeyer."
|
|||
(destroy-nodes-matching *compute* #(= (.getGroup %) "fred"))
|
||||
(is (terminated? (first (nodes-in-group *compute* "fred")))))
|
||||
|
||||
(defn localhost? [node]
|
||||
"Returns true if the localhost address is in the node's private ips"
|
||||
(seq? (some #(= (InetAddress/getLocalHost) %) (private-ips node))))
|
||||
|
||||
(deftest compound-predicate-test
|
||||
(is (create-node *compute* "my-group" (build-template *compute* {})))
|
||||
(is (= 0 (count (nodes-with-details-matching *compute* #(and (suspended? %) (not (localhost? %)))))))
|
||||
(is (= 0 (count (nodes-with-details-matching *compute* #(and (suspended? %) (localhost? %))))))
|
||||
(is (= 0 (count (nodes-with-details-matching *compute* #(and (running? %) (localhost? %))))))
|
||||
(is (= 1 (count (nodes-with-details-matching *compute* #(and (running? %) (not (localhost? %))))))))
|
||||
|
||||
(deftest build-template-test
|
||||
(let [service (compute-service "stub" "user" "password")]
|
||||
(testing "nullary"
|
||||
|
|
Loading…
Reference in New Issue