babashka/test/babashka/pod_test.clj

30 lines
1.3 KiB
Clojure
Raw Normal View History

2020-05-06 19:14:14 +00:00
(ns babashka.pod-test
(:require [babashka.main :as main]
[babashka.test-utils :as tu]
2020-05-06 19:14:14 +00:00
[clojure.edn :as edn]
[clojure.test :as t :refer [deftest is]]))
(deftest pod-test
2020-08-26 16:16:11 +00:00
(if (= "true" (System/getenv "BABASHKA_POD_TEST"))
(let [native? tu/native?
windows? main/windows?
2020-08-26 16:16:11 +00:00
sw (java.io.StringWriter.)
res (apply tu/bb {:err sw}
(cond-> ["-f" "test-resources/pod.clj"]
native?
(conj "--native")
windows?
(conj "--windows")))
2020-08-26 16:16:11 +00:00
err (str sw)]
(is (= "6\n1\n2\n3\n4\n5\n6\n7\n8\n9\n\"Illegal arguments / {:args (1 2 3)}\"\n(\"hello\" \"print\" \"this\" \"debugging\" \"message\")\ntrue\n" res))
(when-not tu/native?
(is (= "(\"hello\" \"print\" \"this\" \"error\")\n" (tu/normalize err))))
2020-08-26 16:16:11 +00:00
(is (= {:a 1 :b 2}
(edn/read-string
(apply tu/bb nil (cond-> ["-f" "test-resources/pod.clj" "--json"]
native?
(conj "--native")
windows?
(conj "--windows")))))))
2020-08-26 16:16:11 +00:00
(println "Skipping pod test because BABASHKA_POD_TEST isn't set to true.")))