This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-02
Channels
- # announcements (12)
- # asami (5)
- # aws (3)
- # babashka (12)
- # beginners (86)
- # calva (14)
- # chlorine-clover (3)
- # cider (13)
- # clara (8)
- # cljdoc (1)
- # cljfx (2)
- # cljsrn (1)
- # clojure (69)
- # clojure-berlin (6)
- # clojure-czech (14)
- # clojure-dev (17)
- # clojure-europe (76)
- # clojure-france (14)
- # clojure-nl (43)
- # clojure-norway (6)
- # clojure-spec (7)
- # clojure-uk (13)
- # clojurescript (4)
- # code-reviews (1)
- # conjure (16)
- # cursive (2)
- # data-science (3)
- # datascript (1)
- # datomic (41)
- # events (4)
- # fulcro (9)
- # hugsql (3)
- # instaparse (5)
- # jobs (3)
- # malli (1)
- # mid-cities-meetup (1)
- # nrepl (22)
- # off-topic (25)
- # onyx (1)
- # pedestal (3)
- # remote-jobs (3)
- # shadow-cljs (61)
- # sql (22)
- # xtdb (12)
I have a question, kinda related to Babashka, but also to Clojure in common.
In my namespace I use the bootleg pod and the glob
namespace to parse a directory. Now I tried with refdef to mock the namespace, but the function isn't called.
(ns static-website.core-test
(:require [babashka.pods :as pods]
[clojure.test :refer [deftest testing is]]
[static-website.core :as sw]
))
(pods/load-pod "bootleg")
(require '[pod.retrogradeorbit.bootleg.glob :refer [glob]])
(deftest path->glob
(testing "correct parsing of a path"
(with-redefs [glob (fn [path] [(str path "file1.yaml" )])]
(is (= ["resource/file1.yaml"] (sw/path->glob "resource"))))))
Where is glob
being called? The one you redefine is probably not the same as the one you call indirectly. I’m guessing this would be because of the nature of how pods work
Could be pod impl related, but I think we should support that, so feel free to post an issue
Hmm, this does seem to work:
(ns static-website.core-test
(:require [babashka.pods :as pods]
[clojure.test :as t :refer [deftest testing is]]))
(pods/load-pod "bootleg")
(require '[pod.retrogradeorbit.bootleg.glob :refer [glob]])
(deftest path->glob
(testing "correct parsing of a path"
(with-redefs [glob (fn [path] :my-glob)]
(prn (glob 1)))))
(path->glob)
The function to test is implemented as this:
(ns static-website.core
(:require [babashka.pods :as pods]))
(pods/load-pod "bootleg")
(require '[pod.retrogradeorbit.bootleg.glob :refer [glob]])
(defn path->glob
""
[path]
(glob (str path "/data/*.yaml") ))
@U068SUJNT seems to work:
(ns static-website.core-test
(:require [babashka.pods :as pods]))
(pods/load-pod "bootleg")
(require '[pod.retrogradeorbit.bootleg.glob :refer [glob]])
(defn path->glob
""
[path]
(glob (str path "/data/*.yaml") ))
(with-redefs [glob (fn [x] (str "my-glob/" x))]
(path->glob "my-path"))
"my-glob/my-path/data/*.yaml"
Okay then I have to test it again. Thanks
What did I do wrong?