Get rid of :needs-ctx

This commit is contained in:
Michiel Borkent 2020-11-18 17:44:01 +01:00
parent a0418d6622
commit e71ae00d03
2 changed files with 56 additions and 57 deletions

View file

@ -19,9 +19,7 @@
(string? var-value)
(sci/eval-string* ctx var-value))))))
(def load-pod
(with-meta
(fn
(defn load-pod
([ctx pod-spec] (load-pod ctx pod-spec nil))
([ctx pod-spec opts]
(let [env (:env ctx)
@ -68,7 +66,6 @@
(process-namespace ctx {:name ns-name :vars vars}))
(sci/future (impl/processor pod))
{:pod/id (:pod-id pod)})))
{:sci.impl/op :needs-ctx}))
(defn unload-pod
([pod-id] (unload-pod pod-id {}))

View file

@ -7,13 +7,15 @@
(deftest sci-test
(let [out (java.io.StringWriter.)
err (java.io.StringWriter.)
ret (sci/binding [sci/out out
sci/err err]
(sci/eval-string
test-program
{:namespaces {'babashka.pods
{'load-pod pods/load-pod
ctx-ref (volatile! nil)
ctx (sci/init {:namespaces {'babashka.pods
{'load-pod (fn [& args]
(apply pods/load-pod @ctx-ref args))
'invoke pods/invoke
'unload-pod pods/unload-pod}}
:classes {'System System}}))]
:classes {'System System}})
_ (vreset! ctx-ref ctx)
ret (sci/binding [sci/out out
sci/err err]
(sci/eval-string* ctx test-program))]
(assertions out err ret)))