                  (is (= "14:15:45-401" file-name)))))
 
 (deftest swift-write-rows-read-batch-test
-  "This test verifies that read-batch calls function/read-batch with the event
-  that is passed into it."
-  (with-redefs [function/read-batch (fn [event] event)]
-    (let [record (swift/->SwiftWriteRows "http://authurl.com" "username" "apikey")
-          event {:event 1}
-          result (.read-batch record event)]
-      (is (= event result)))))
+  (testing "This test verifies that read-batch calls function/read-batch with the event
+           that is passed into it."
+    (with-redefs [function/read-batch (fn [event] event)]
+      (let [record (swift/->SwiftWriteRows "http://authurl.com" "username" "apikey")
+            event {:event 1}
+            result (.read-batch record event)]
+        (is (= event result))))))
 
 (deftest swift-write-rows-write-batch-test
   (with-redefs [swift/authenticate (fn [auth-url username api-key]

(ns desdemona.plugins.swift-test
  (:require [clojure.test :refer [deftest is]]
            [cheshire.core :as json]
            [camel-snake-kebab.core :refer [->kebab-case-keyword]]
            [clojure.java.io :as io]

    (is (= token got))))

(deftest authenticate-test
  (testing "This test verifies that the authenticate function makes a request to the
           URL specified by the auth-url parameter, and includes the username and api-key
           in the expected JSON format."
    (http/with-fake-routes
      {"http://authurl.com" {:post (fn [req]
                                     (let [body (json/parse-stream (io/reader (req :body)) ->kebab-case-keyword)
                                           username (-> body :auth :rax-kskey:api-key-credentials :username)
                                           api-key (-> body :auth :rax-kskey:api-key-credentials :api-key)]
                                       {:status 200
                                        :headers {}
                                        :body (json/generate-string {:username username
                                                                     :api-key api-key})}))}}
      (let [result (swift/authenticate "http://authurl.com" "username" "apikey")]
        (is (= {:username "username" :api-key "apikey"} result))))))

(deftest create-container-test
  (testing "This test verifies that the create-container function makes a request to the
           URL specified, with the container-name in the path, and includes the given
           auth token as a header."
    (http/with-fake-routes
      {"http://cf-url.com/containername" {:put (fn [req]
                                                 (let [token (-> req :headers (get "X-Auth-Token"))]
                                                   (is (= "authtoken" token))
                                                   {:status 200
                                                    :headers {}
                                                    :body ""}))}}
      (let [result (swift/create-container "http://cf-url.com" "authtoken" "containername")]
        (is (= 200 result))))))

(deftest write-file-test
  (testing "This test verifies that the write-file function makes a request to the URL
           specified, with the container-name and file-name in the path, that it includes
           the auth token as a header, and encodes the given contents as JSON."
    (http/with-fake-routes
      {"http://cf-url.com/containername/filename" {:put (fn [req]
                                                          (let [token (-> req :headers (get "X-Auth-Token"))
                                                                body (json/parse-stream (io/reader (req :body)) ->kebab-case-keyword)]
                                                            (is (= "authtoken" token))
                                                            (is (= {:contents 123} body))
                                                            {:status 200
                                                             :headers {}
                                                             :body ""}))}}
      (let [result (swift/write-file "http://cf-url.com" "authtoken" "containername" "filename" {:contents 123})]
        (is (= 200 result))))))

(deftest calculate-container-name-test
  (freeze-time (t/date-time 2016 6 8 4 15 45 401)
