1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
(ns puppetlabs.config.typesafe_test
(:import (java.io FileInputStream))
(:require [puppetlabs.config.typesafe :as ts]
[clojure.test :refer :all]))
(def test-files-dir "./dev-resources/puppetlabs/config/file/")
(deftest configfile->map-test
(testing "can parse .properties file with nested data structures"
(let [cfg (ts/config-file->map (str test-files-dir "config.properties"))]
(is (= {:foo {:bar "barbar"
:baz "bazbaz"
:bam 42
:bap {:boozle "boozleboozle"}}}
cfg))))
(testing "can parse .json file with nested data structures"
(let [cfg (ts/config-file->map (str test-files-dir "config.json"))]
(is (= {:foo {:bar "barbar"
:baz "bazbaz"
:bam 42
:bap {:boozle "boozleboozle"
:bip [1 2 {:hi "there"} 3]}}}
cfg))))
(testing "can parse .conf file with nested data structures"
(let [cfg (ts/config-file->map (str test-files-dir "config.conf"))]
(is (= {:foo {:bar "barbar"
:baz "bazbaz"
:bam 42
:bap {:boozle "boozleboozle"
:bip [1 2 {:hi "there"} 3]}}}
cfg))))
(testing "can parse .conf file with substitution variables"
(let [cfg (ts/config-file->map (str test-files-dir "substitution.conf"))]
(is (= {:top {:henry "text"
:bob "text"}}
cfg)))))
(deftest reader->map-test
(testing "can parse .properties stream with nested data structures"
(let [cfg (ts/reader->map
(FileInputStream. (str test-files-dir "config.properties"))
:properties)]
(is (= {:foo {:bar "barbar"
:baz "bazbaz"
:bam 42
:bap {:boozle "boozleboozle"}}}
cfg))))
(testing "can parse .json stream with nested data structures"
(let [cfg (ts/reader->map
(FileInputStream. (str test-files-dir "config.json"))
:json)]
(is (= {:foo {:bar "barbar"
:baz "bazbaz"
:bam 42
:bap {:boozle "boozleboozle"
:bip [1 2 {:hi "there"} 3]}}}
cfg))))
(testing "can parse .conf stream with nested data structures"
(let [cfg (ts/reader->map
(FileInputStream. (str test-files-dir "config.conf"))
:conf)]
(is (= {:foo {:bar "barbar"
:baz "bazbaz"
:bam 42
:bap {:boozle "boozleboozle"
:bip [1 2 {:hi "there"} 3]}}}
cfg))))
(testing "can parse .conf file with substitution variables"
(let [cfg (ts/reader->map
(FileInputStream. (str test-files-dir "substitution.conf"))
:conf)]
(is (= {:top {:henry "text"
:bob "text"}}
cfg)))))
|