mirror of https://github.com/apache/jclouds.git
Run clojure blobstore tests inside with-blobstore.
This commit is contained in:
parent
1da7c5a6b6
commit
5311b05192
|
@ -8,9 +8,10 @@
|
||||||
(def stub-blobstore (.getBlobStore stub-context))
|
(def stub-blobstore (.getBlobStore stub-context))
|
||||||
|
|
||||||
(defn clean-stub-fixture [f]
|
(defn clean-stub-fixture [f]
|
||||||
|
(with-blobstore [stub-blobstore]
|
||||||
(doseq [container (containers)]
|
(doseq [container (containers)]
|
||||||
(delete-container (.getName container)))
|
(delete-container (.getName container)))
|
||||||
(f))
|
(f)))
|
||||||
|
|
||||||
(use-fixtures :each clean-stub-fixture)
|
(use-fixtures :each clean-stub-fixture)
|
||||||
|
|
||||||
|
@ -34,19 +35,13 @@
|
||||||
|
|
||||||
(deftest create-existing-container-test
|
(deftest create-existing-container-test
|
||||||
(is (not (container-exists? stub-blobstore "")))
|
(is (not (container-exists? stub-blobstore "")))
|
||||||
(with-blobstore [stub-blobstore]
|
(is (not (container-exists? "")))
|
||||||
(is (not (container-exists? ""))))
|
|
||||||
(is (create-container stub-blobstore "fred"))
|
(is (create-container stub-blobstore "fred"))
|
||||||
(is (container-exists? stub-blobstore "fred"))
|
(is (container-exists? stub-blobstore "fred")))
|
||||||
(with-blobstore [stub-blobstore]
|
|
||||||
(is (container-exists? "fred"))))
|
|
||||||
|
|
||||||
(deftest create-container-test
|
(deftest create-container-test
|
||||||
(is (create-container stub-blobstore "fred"))
|
(is (create-container stub-blobstore "fred"))
|
||||||
(is (container-exists? stub-blobstore "fred"))
|
(is (container-exists? stub-blobstore "fred")))
|
||||||
(with-blobstore [stub-blobstore]
|
|
||||||
(is (create-container "fred"))
|
|
||||||
(is (container-exists? "fred"))))
|
|
||||||
|
|
||||||
(deftest containers-test
|
(deftest containers-test
|
||||||
(is (empty? (containers stub-blobstore)))
|
(is (empty? (containers stub-blobstore)))
|
||||||
|
@ -54,21 +49,6 @@
|
||||||
(is (= 1 (count (containers stub-blobstore)))))
|
(is (= 1 (count (containers stub-blobstore)))))
|
||||||
|
|
||||||
(deftest list-container-test
|
(deftest list-container-test
|
||||||
(is (create-container stub-blobstore "container"))
|
|
||||||
(is (empty? (list-container stub-blobstore "container")))
|
|
||||||
(is (create-blob stub-blobstore "container" "blob1" "blob1"))
|
|
||||||
(is (create-blob stub-blobstore "container" "blob2" "blob2"))
|
|
||||||
(is (= 2 (count (list-container stub-blobstore "container"))))
|
|
||||||
(is (= 1 (count (list-container stub-blobstore "container" :max-results 1))))
|
|
||||||
(create-directory stub-blobstore "container" "dir")
|
|
||||||
(is (create-blob stub-blobstore "container" "dir/blob2" "blob2"))
|
|
||||||
(is (= 3 (count (list-container stub-blobstore "container"))))
|
|
||||||
(is (= 4 (count (list-container stub-blobstore "container" :recursive))))
|
|
||||||
(is (= 1 (count (list-container stub-blobstore "container"
|
|
||||||
:in-directory "dir")))))
|
|
||||||
|
|
||||||
(deftest list-container-with-blobstore-test
|
|
||||||
(with-blobstore [stub-blobstore]
|
|
||||||
(is (create-container "container"))
|
(is (create-container "container"))
|
||||||
(is (empty? (list-container "container")))
|
(is (empty? (list-container "container")))
|
||||||
(is (create-blob "container" "blob1" "blob1"))
|
(is (create-blob "container" "blob1" "blob1"))
|
||||||
|
@ -79,10 +59,9 @@
|
||||||
(is (create-blob "container" "dir/blob2" "blob2"))
|
(is (create-blob "container" "dir/blob2" "blob2"))
|
||||||
(is (= 3 (count (list-container "container"))))
|
(is (= 3 (count (list-container "container"))))
|
||||||
(is (= 4 (count (list-container "container" :recursive))))
|
(is (= 4 (count (list-container "container" :recursive))))
|
||||||
(is (= 1 (count (list-container "container" :in-directory "dir"))))))
|
(is (= 1 (count (list-container "container" :in-directory "dir")))))
|
||||||
|
|
||||||
(deftest download-blob-test
|
(deftest download-blob-test
|
||||||
(with-blobstore [stub-blobstore]
|
|
||||||
(let [name "test"
|
(let [name "test"
|
||||||
container-name "test-container"
|
container-name "test-container"
|
||||||
data "test content"
|
data "test content"
|
||||||
|
@ -90,7 +69,7 @@
|
||||||
(create-container container-name)
|
(create-container container-name)
|
||||||
(create-blob container-name name data)
|
(create-blob container-name name data)
|
||||||
(download-blob container-name name baos)
|
(download-blob container-name name baos)
|
||||||
(is (= data (.toString baos))))))
|
(is (= data (.toString baos)))))
|
||||||
|
|
||||||
;; TODO: more tests involving blob-specific functions
|
;; TODO: more tests involving blob-specific functions
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue