Commit 1bc9f22c authored by Bruno Burke's avatar Bruno Burke 🍔
Browse files

add test with fixture

parent 1001773c
Pipeline #34766 passed with stages
in 1 minute and 25 seconds
(ns document-storage.core-test
(:require [clojure.test :refer :all]
[document-storage.core :refer :all]))
[document-storage.core :as ds]
[ :as io]
[fipp.edn :refer [pprint] :rename {pprint fipp}]))
(deftest a-test
(testing "I pass."
(is (= 1 1))))
(defn create-storage [directory]
(let [config-file (str directory "/" "config.edn")
config {:repositories
{:testrepo {}}}]
(io/make-parents config-file)
(spit config-file (with-out-str (fipp config)))))
(defn delete-folder
[f1 & [silently]]
(when (.isDirectory (io/file f1))
(doseq [f2 (.listFiles (io/file f1))]
(delete-folder f2 silently)))
(io/delete-file f1 silently))
(defn destroy-storage [directory]
(delete-folder directory))
(defn storage-fixture [f]
(create-storage "teststorage")
(ds/init-storage "teststorage")
(destroy-storage "teststorage"))
(use-fixtures :once storage-fixture)
(deftest simple-test
(testing "save basic structure and load it"
(let [structure {:a 5 :c [1 2 3 4 99 5 -4]}
id "simple-test1"
repo :testrepo]
(ds/save-document id structure :repository repo)
(is (= structure
(ds/load-document id :repository repo))))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment