Back

resource-resolver (clj)

(source)

function

(resource-resolver _ include)

Examples

aero
(ns aero.core-test
  (:require
   [aero.core :refer [read-config reader
                      #?@(:clj [deferred resource-resolver root-resolver])
                      #?(:cljs Deferred)]
    #?@(:cljs [:refer-macros [deferred]])]
   [clojure.test :refer [deftest is testing are]]
   #?@(:clj [[clojure.java.io :as io]]
       :cljs [[goog.object :as gobj]
              [goog.string :as gstring]
              goog.string.format
              [cljs.tools.reader.reader-types
               :refer [source-logging-push-back-reader]]]))
  #?(:clj (:import [aero.core Deferred])))

#?(:clj
   (deftest resolver-tests
     (let [source (io/resource "aero/includes.edn")]
       (is (read-config source {:profile :relative}))
       (is (read-config source {:profile :relative-abs}))
       (is (read-config source {:profile :resource :resolver resource-resolver}))
       (is (read-config source {:profile :file :resolver root-resolver}))
       (is (read-config (-> source slurp string-reader)
                        {:profile :relative-abs}))
       (is (read-config source {:profile  :map
                                :resolver {:sub-includes (io/resource "aero/sub/includes.edn")
                                           :valid-file   (io/resource "aero/valid.edn")}}))
       (is (:aero/missing-include (read-config source {:profile :file-does-not-exist}))))))