Skip to content
Snippets Groups Projects
Commit 4e42336e authored by Elliott Shugerman's avatar Elliott Shugerman
Browse files

progress w/ janet

parent 07a14c05
No related branches found
No related tags found
No related merge requests found
......@@ -2,4 +2,5 @@
:dependencies ["https://github.com/pyrmont/testament"
"https://github.com/andrewchambers/janet-sh"
"https://github.com/andrewchambers/jfmt"
"https://github.com/zenlor/janet-csv"
])
(import testament :prefix "" :exit true)
(import sh)
(import csv)
(def bootstrap-database "postgres")
(def base-env
@{"POSTGRES_CONTAINER_NAME" "postgres"
"BACKUP_SERVICE_CONTAINER_NAME" "backup-service"
"POSTGRES_USER" "postgres"
"POSTGRES_PASSWORD" "secret"
"SEED_DATABASE" "pagila"})
(def version-pairs
[@{"POSTGRES_VERSION" "12" "ALPINE_VERSION" "3.12"}
@{"POSTGRES_VERSION" "13" "ALPINE_VERSION" "3.14"}
@{"POSTGRES_VERSION" "14" "ALPINE_VERSION" "3.16"}
@{"POSTGRES_VERSION" "15" "ALPINE_VERSION" "3.17"}
@{"POSTGRES_VERSION" "16" "ALPINE_VERSION" "3.19"}])
(defn export-env [env]
(loop [[name val] :pairs env]
(os/setenv name val)))
(defn create-services []
(print "Creating services")
(sh/$ docker compose --progress=plain up --build --detach))
(defn delete-services []
(print "Deleting services")
(sh/$ docker compose --progress=plain down))
(defn exec-sql [sql &opt database]
(default database (os/getenv "SEED_DATABASE"))
(let [data (sh/$< echo ,sql | docker exec -i ,(os/getenv "POSTGRES_CONTAINER_NAME") psql
--csv
--echo-errors
--variable ON_ERROR_STOP=1
--username ,(os/getenv "POSTGRES_USER")
--dbname ,database)]
(csv/parse data true)))
(deftest two-plus-two
(is (= 5 (+ 2 2)) "2 + 2 = 5"))
......@@ -13,5 +52,5 @@
(deftest echo-hi-fail
(assert-equal (string/trim (sh/$< echo "hi")) "bye"))
(run-tests!)
# (run-tests!)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment