This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-11
Channels
- # announcements (6)
- # babashka (35)
- # beginners (6)
- # biff (2)
- # calva (1)
- # cider (16)
- # clj-kondo (14)
- # clojure (176)
- # clojure-austin (13)
- # clojure-europe (7)
- # clojure-norway (6)
- # clojure-uk (12)
- # clojurescript (4)
- # cursive (11)
- # data-science (3)
- # datalog (10)
- # datomic (45)
- # events (1)
- # fulcro (2)
- # hyperfiddle (29)
- # leiningen (14)
- # lsp (2)
- # meander (2)
- # off-topic (24)
- # polylith (5)
- # re-frame (2)
- # shadow-cljs (21)
- # specter (14)
- # tools-deps (16)
- # xtdb (5)
probably a beginner mistake — trying to run http-server
in a docker-container based on babashka/babashka
, I’m greeted with Couldn't find 'java'. Please set JAVA_HOME.
— what am I missing?
If you are using dependencies in bb.edn
then you need to have java installed to download them
OK. so I guess that’s what happens at runtime in the http-server
script https://github.com/babashka/http-server#babashka?
any chance to use the docker image for this then? I guess not
if you want to download dependencies without java, it's probably better to make an uberjar and then add this to your docker image
hmm hmm thanks
I think this is becoming too much overhead, if I just found a way to start a binary for having tests run against that service, I wouldn’t need docker in the first place
for simple dependencies you can also just git clone the dependency and add manually to the classpath:
bb -cp ~/Downloads/http-server/src ...
sorry — X vs Y problem here on my end
let me start over: I’ve got two simple http/get API tests that I’d like to run against a service. can you give me a hint on how to start the service before tests and tear it down after? 😅
only the tests are running in bb, the service is a little golang-built binary
I’d like to do API tests like
(deftest authorized-cars
(testing "bob is authorized to list all cars"
(let [status (:status (request {"Authorization" "bob"}))]
(is (= 200 status)))))
ohh I see why this is confusing sorrythe piece I forgot to mention: the app needs to retrieve something via HTTP from a static file server
I’m sorry it’s really hot today 💦
> can you give me a hint on how to start the service before tests and tear it down after? clojure.test has fixtures for this
so, my initial try was to start the service, and some file server, via docker-compose, and then have a bb run test:api
job.
now, I’m trying to do it all from bb, starting the service and the auxilliary file server
clojure.test. thanks, I’ll go read up on that end.
I have an example of running a server for tests here: https://github.com/babashka/http-client/blob/main/test/babashka/http_client_test.clj
oh this is great thank you
that fn calls as-path on the argument, which calls io/file on it, so it gets treated as a relative path, so it's essentially just the current directory
for example:
user=> (-> (fs/path "") .toAbsolutePath)
#object[sun.nio.fs.UnixPath 0x3bc3dc17 "/home/bob"]
Looks like it yeah, no idea about the rationale for why an empty UnixPath resolves to current dir, but I guess that's just a java thing and nothing wrong on this end then!
I imagine it's sort of a circumstantial outcome of the rules of the File class - if the path doesn't start with a prefix that signifies it's an absolute path, it's relative, and since it's relative, it appends the string path to user.dir
, and so appending an empty string returns the path at user.dir