Permalink
Browse files

Introduce a few basic tests.

  • Loading branch information...
mrowe committed Oct 26, 2012
1 parent 890d096 commit 3a3d68a4751386235eeae17cd59d2475cd638363
Showing with 55 additions and 0 deletions.
  1. +2 −0 src/aws/sdk/ec2.clj
  2. +53 −0 test/aws/sdk/ec2_test.clj
View
@@ -23,6 +23,8 @@
com.amazonaws.services.ec2.model.StopInstancesRequest
com.amazonaws.services.ec2.model.Tag))
+(use 'clojure.string)
+
(defn- ec2-client*
"Create an AmazonEC2Client instance from a map of credentials."
[cred]
View
@@ -0,0 +1,53 @@
+(ns aws.sdk.ec2-test
+ (:use clojure.test
+ aws.sdk.ec2))
+
+
+;;
+;; filters
+;;
+
+(let [filter (aws-filter "foo" "bar")]
+
+ (deftest filter-is-a-vector
+ (testing "AWS filter provides a vector"
+ (is (vector? filter))))
+
+ (deftest filter-sets-name-and-one-value
+ (testing "AWS filter"
+ (let [f (first filter)]
+ (is (= (.getName f) "foo"))
+ (is (= (.getValues f) '("bar"))))))
+
+ (deftest filter-sets-two-values
+ (testing "AWS filter"
+ (let [filter (first (aws-filter "foo" "bar" "baz"))]
+ (is (= (.getValues filter) '("bar" "baz")))))))
+
+
+(let [filter (image-id-filter "foo")]
+
+ (deftest image-id-filter-is-a-describe-images-request
+ (testing "Image id filter is a DescribeImagesRequest"
+ (is (= (.getClass filter) com.amazonaws.services.ec2.model.DescribeImagesRequest))))
+
+ (let [f (first (.getFilters filter))]
+
+ (deftest image-id-filter-sets-image-id-filter
+ (testing "Image id filter uses image-id filter"
+ (is (= (.getName f) "image-id"))))
+
+ (deftest image-id-filter-sets-image-id
+ (testing "Image id filter uses given image id"
+ (is (= (first (.getValues f)) "foo"))))))
+
+
+(let [filter (image-owner-filter "foo")]
+
+ (deftest image-owner-filter-is-a-describe-images-request
+ (testing "Image owner filter is a DescribeImagesRequest"
+ (is (= (.getClass filter) com.amazonaws.services.ec2.model.DescribeImagesRequest))))
+
+ (deftest image-own-filter-sets-owner
+ (testing "Image owner filter sets a given owner"
+ (is (= (first (.getOwners filter)) "foo")))))

0 comments on commit 3a3d68a

Please sign in to comment.