It looks like the issue is that korma.core/select is a macro, and has
already expanded by the time you redef it.

https://github.com/korma/Korma/blob/master/src/korma/core.clj#L113


On Fri, Mar 7, 2014 at 12:59 PM, Mark Watson <mkw5...@gmail.com> wrote:

> I have a web service that uses Korma for interacting with my db. To mock
> data for unit tests I want to re-bind korma.core/select to return known
> data and not hit a db.
>
> Currently I have a db ns:
>
> (nsservices.db
>   (:require [korma.core :refer :all]
>                [korma.db :refer :all]))
>
>
> With a function 'func-select' that calls korma.core/select
>
> And a test ns:
>
> (ns ad-gallery-services.core-test
>   (:require [clojure.test :refer :all]
>             [ad-gallery-services.db :refer :all]
>             [ad-gallery-services.web :refer :all]))
>
> (deftest func-select-test
>   (testing "Return nil if select returns empty"
>     (with-redefs [korma.core/select (fn [& _] [])]
>       (require 'ad-gallery-services.db :reload)
>       (is (= (func-select 1)
>              nil)))))
>
>
> However, it keeps throwing the exception:
>
>     ArityException Wrong number of args (1) passed to: core$where
>
> Why is it even evaluating 'where', and (most importantly) how can I mock
> this data?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to