Skip to content

Commit

Permalink
add test for deps-file write from new
Browse files Browse the repository at this point in the history
- add a minimal template from a local root for use in the test
- add test that checks the write to deps file, when it exists and when it doesn't
  • Loading branch information
bobisageek committed Oct 17, 2024
1 parent 1ee0238 commit 7efa916
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions test-resources/new/minimal-template/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:paths ["resources"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
25 changes: 25 additions & 0 deletions tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,31 @@
(is (= (edn/read-string (slurp (fs/file "test-resources/new/my-scratch/deps.edn")))
(edn/read-string (slurp (fs/file (str target-dir "/deps.edn"))))))))))

(deftest deps-file-write-test
; create a minimal template at a local root
(let [template-dir (fs/create-temp-dir {:prefix "neilnew"})
_ (fs/copy-tree "test-resources/new/minimal-template/" template-dir)]
(testing "creating from a template with a deps.edn file adds a neil alias"
(let [target-dir (fs/create-temp-dir)]
(run-new-command "emptyish/emptyish" "foo/bar" (str target-dir)
"--local/root" (str template-dir)
"--overwrite" "true")
(is (str/includes? (slurp (fs/file target-dir "deps.edn")) ":neil"))
(fs/delete-tree target-dir)))
; remove deps.edn from the template output
(fs/delete (fs/file template-dir "resources" "emptyish" "emptyish" "root" "deps.edn"))
(testing "creating from a template without deps.edn doesn't throw"
(let [target-dir (fs/create-temp-dir)]
(run-new-command "emptyish/emptyish" "foo/bar" (str target-dir)
"--local/root" (str template-dir)
"--overwrite" "true")
(is (not (fs/exists? (fs/file target-dir "deps.edn"))))
(fs/delete-tree target-dir)))
; delete that template we created
(fs/delete-tree template-dir)))



(deftest clj-neil-new-test
(let [{:keys [out err]} @(deps/clojure ["-M:neil" "new" "--help"]
{:dir "tests-clj"
Expand Down

0 comments on commit 7efa916

Please sign in to comment.