Back

resolve-fn (clj)

(source)

function

(resolve-fn mig-name mig-ns fn-name)
Basically ns-resolve with some error-checking

Examples

migratus
(ns migratus.test.migration.edn
  (:require [clojure.java.io :as io]
            [clojure.test :refer :all]
            [migratus.core :as core]
            [migratus.migration.edn :refer :all]
            migratus.mock
            [migratus.protocols :as proto]
            [migratus.utils :as utils])
  (:import java.io.File))

(deftest test-resolve-fn
  (require test-namespace)
  (is (var? (resolve-fn "test-mig" test-namespace "migrate-up")))
  (is (var? (resolve-fn "test-mig" test-namespace 'migrate-up)))
  (is (var? (resolve-fn "test-mig" test-namespace :migrate-up)))
  (is (thrown-with-msg?
       IllegalArgumentException
       #"Unable to resolve"
       (resolve-fn "test-mig" test-namespace "not-a-fn")))
  (is (thrown-with-msg?
       IllegalArgumentException
       #"Namespaced symbol not allowed"
       (resolve-fn "test-mig" test-namespace "clojure.core/map"))))