Search code examples
unit-testingclojurecompojurecompojure-api

Exception when attempting to run Cloverage with compojure auth middleware


Cloverage is now failing after I adding role based authentication to my compojure api. Whilst running lein cloverage I get this exception:

Exception in thread "main" java.lang.IllegalArgumentException: No method in multimethod 'restructure-param' for dispatch value: :auth-roles, compiling:(/private/var/folders/w_/yt926bqs21g44f257yz05ctsjbv948/T/form-init3368607975292148784.clj:1:125)

Here is my auth middleware:

(defmethod compojure.api.meta/restructure-param :auth-roles
[_ required-roles acc]

(update-in acc [:middleware] conj [require-roles required-roles]))

Solution

  • See github issue: https://github.com/cloverage/cloverage/issues/164#issuecomment-281673566

    (defmethod compojure.api.meta/restructure-param :auth-roles
      [_ required-roles acc]
    
      (update-in acc [:middleware] conj [`require-roles required-roles]))