made options for selecting nodes explicit in clj test

This commit is contained in:
Adrian Cole 2011-05-06 15:49:18 -07:00
parent adafc4f5bf
commit 9e4cb6a758
1 changed files with 4 additions and 0 deletions

View File

@ -61,7 +61,11 @@ list, Alan Dipert and MeikelBrandmeyer."
(is (create-node *compute* "fred" (build-template *compute* {} ))) (is (create-node *compute* "fred" (build-template *compute* {} )))
(is (= 1 (count (nodes *compute*)))) (is (= 1 (count (nodes *compute*))))
(is (= 1 (count (nodes-in-group *compute* "fred")))) (is (= 1 (count (nodes-in-group *compute* "fred"))))
;; pass in a function that selects node metadata based on NodeMetadata field
(is (= 1 (count (nodes-with-details-matching *compute* (in-group "fred"))))) (is (= 1 (count (nodes-with-details-matching *compute* (in-group "fred")))))
;; or make your query inline
(is (= 1 (count (nodes-with-details-matching *compute* #(= (.getGroup %) "fred")))))
;; or get real fancy, and use the underlying Predicate object jclouds uses
(is (= 1 (count (nodes-with-details-matching *compute* (is (= 1 (count (nodes-with-details-matching *compute*
(reify com.google.common.base.Predicate (reify com.google.common.base.Predicate
(apply [this input] (= (.getGroup input) "fred"))))))) (apply [this input] (= (.getGroup input) "fred")))))))