Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rads committed Jul 23, 2022
1 parent 6719349 commit 5d64c53
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test-resources/new/my-kit/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:paths ["src"]
:deps {}}
12 changes: 12 additions & 0 deletions test-resources/new/my-kit/src/scratch.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns scratch
"FIXME: my new io.github.rads/kit project.")

(defn exec
"Invoke me with clojure -X scratch/exec"
[opts]
(println "exec with" opts))

(defn -main
"Invoke me with clojure -M -m scratch"
[& args]
(println "-main with" args))
2 changes: 2 additions & 0 deletions test-resources/new/my-scratch/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:paths ["src"]
:deps {}}
12 changes: 12 additions & 0 deletions test-resources/new/my-scratch/src/scratch.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns scratch
"FIXME: my new org.corfield.new/scratch project.")

(defn exec
"Invoke me with clojure -X scratch/exec"
[opts]
(println "exec with" opts))

(defn -main
"Invoke me with clojure -M -m scratch"
[& args]
(println "-main with" args))
17 changes: 17 additions & 0 deletions tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,22 @@
(is (thrown-with-msg? Exception #"nonExistentLicense"
(run-license out-file "add" "nonExistentLicense"))))))

(deftest new-scratch-test
(let [target-dir (str (fs/temp-dir) "/my-scratch")]
(spit (test-file "deps.edn") "{}")
(neil (str "new scratch my-scratch :overwrite true :target-dir " target-dir))
(is (= (slurp (fs/file "test-resources/new/my-scratch/src/scratch.clj"))
(slurp (fs/file (str target-dir "/src/scratch.clj")))))
(is (= (slurp (fs/file "test-resources/new/my-scratch/deps.edn"))
(slurp (fs/file (str target-dir "/deps.edn")))))))

(deftest new-remote-test
(let [target-dir (str (fs/temp-dir) "/my-kit")]
(spit (test-file "deps.edn") "{}")
(neil (str "new io.github.rads/kit my-kit :overwrite true :target-dir " target-dir))
(is (= (slurp (fs/file "test-resources/new/my-kit/src/scratch.clj"))
(slurp (fs/file (str target-dir "/src/scratch.clj")))))
(is (= (slurp (fs/file "test-resources/new/my-kit/deps.edn"))
(slurp (fs/file (str target-dir "/deps.edn")))))))
(when (= *file* (System/getProperty "babashka.file"))
(t/run-tests *ns*))

0 comments on commit 5d64c53

Please sign in to comment.