From fa117f663d0719b68181005b2601fe48e92a3020 Mon Sep 17 00:00:00 2001 From: Radford Smith <11401+rads@users.noreply.github.com> Date: Sat, 23 Jul 2022 07:43:46 -0700 Subject: [PATCH] Update tests --- tests.clj | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests.clj b/tests.clj index 13585bcd..e110974d 100644 --- a/tests.clj +++ b/tests.clj @@ -82,19 +82,32 @@ (is (thrown-with-msg? Exception #"nonExistentLicense" (run-license out-file "add" "nonExistentLicense")))))) +(defn run-new-command [& args] + (-> @(process (concat ["./neil" "new"] args) {:out :string}) + :out + edn/read-string)) + (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"))))))) + (let [edn (run-new-command "scratch" "my-scratch" + ":target-dir" target-dir + ":dry-run" "true" + ":overwrite" "true")] + (is (= {:template-deps nil + :create-opts {:template "scratch" + :overwrite true + :target-dir target-dir + :name "my-scratch"}} + edn))))) (deftest new-remote-test (let [target-dir (str (fs/temp-dir) "/my-kit")] + (fs/delete-tree target-dir) (spit (test-file "deps.edn") "{}") - (neil (str "new io.github.rads/kit my-kit :overwrite true :target-dir " target-dir)) + (run-new-command "io.github.rads/kit" "my-kit" + ":target-dir" target-dir + ":overwrite" "true") (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"))