; Copyright (c) meissa. All rights reserved. ; The use and distribution terms for this software are covered by the ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) ; which can be found in the file epl-v10.html at the root of this distribution. ; By using this software in any fashion, you are agreeing to be bound by ; the terms of this license. ; You must not remove this notice, or any other, from this software. (ns cryogen-core.classpath-able-io-test (:require [clojure.test :refer :all] [clojure.string :as s] [clojure.java.io :as io] [cryogen-core.classpath-able-io :as sut])) (set-fn-validation! true) (def theme "bootstrap4-test") (def target "target/tmp") (defn verify-file-exists [path] (.exists (io/file path))) (defn verify-dir-exists [path] (and (verify-file-exists path) (.isDirectory (io/file path)))) (deftest test-get-file-paths-recursive (is (= ["js/dummy.js"] (sut/get-file-paths-recursive "templates/themes/bootstrap4-test" ["js/dummy.js"])) (is (= ["/css/dummy.css" "css" "/html/404.html" "/html/403.html" "/html" "html" "js/subdir/subdummy.js" "js/subdir/test.js" "js/subdir" "js/dummy.js" "js"] (sut/get-file-paths-recursive "templates/themes/bootstrap4-test" [""]))))) ; (deftest test-delete-file-recursive ; (is ; (do ; (.mkdir (io/file target)) ; (sut/delete-file-recursive (seq (io/file target))) ; (not (verify-dir-exists target))))) (deftest test-file-from-cp-or-filesystem (is (.exists (sut/file-from-cp-or-filesystem "./test-resources/" "templates/themes/bootstrap4-test/js"))) (is (.exists (sut/file-from-cp-or-filesystem "./" ".gitkeep")))) (deftest test-filter-for-ignore-patterns (is (= ["file.js"] (sut/filter-for-ignore-patterns #".*\.ignore" ["file.js" "file.ignore"])))) (deftest test-file-from-cp (is (sut/file-from-cp ".gitkeep"))) (deftest test-file-from-cp-or-filesystem (is (.exists (sut/file-from-cp-or-filesystem "./test-resources/" "templates/themes/bootstrap4-test/js"))) (is (.exists (sut/file-from-cp-or-filesystem "./" ".gitkeep")))) (deftest test-copy-resources-from-theme (is (do (sut/copy-resources-from-theme "./" theme target "") (and (verify-dir-exists (str target "/templates/themes/bootstrap4-test/js")) (verify-file-exists (str target "/templates/themes/bootstrap4-test/js/dummy.js")) (verify-dir-exists (str target "/templates/themes/bootstrap4-test/js/subdir")) (verify-file-exists (str target "/templates/themes/bootstrap4-test/js/subdir/subdummy.js")) (verify-file-exists (str target "/templates/themes/bootstrap4-test/css/dummy.css")) (verify-file-exists (str target "/templates/themes/bootstrap4-test/html/404.html")) ))))