diff --git a/src/project_checkup/core.clj b/src/project_checkup/core.clj --- a/src/project_checkup/core.clj +++ b/src/project_checkup/core.clj @@ -4,7 +4,7 @@ (:require [clojure.java.shell :as shell] [clojure.string :as string])) -(defn get-extension [path] (re-find #"\.[a-zA-Z]+" path)) +(defn get-extension [path] (re-find #"\.[a-zA-Z]+$" path)) (defn gather-project-info "Creates a dictionary of project information" @@ -38,7 +38,7 @@ (defn check-readme [project] (let [{files :files } project] - (boolean (some #{"README.md" "README.txt" "README.mkd"} files)) )) + (boolean (some #{"README.md" "README.txt" "README.mkd" "README"} files)) )) (defn check-untracked [project] (let [{untracked :untracked-files } project] @@ -50,8 +50,7 @@ (some #{"TODO" "TODO.txt" } files)))) (defn check-readme-placeholders [project] - (= (count (re-find #"(FIXME|TODO)" (:readme project) )) 0) - ) + (= (count (re-find #"(FIXME|TODO)" (:readme project) )) 0)) (def checks [{:name "Has VCS" diff --git a/test/project_checkup/core_test.clj b/test/project_checkup/core_test.clj --- a/test/project_checkup/core_test.clj +++ b/test/project_checkup/core_test.clj @@ -2,6 +2,43 @@ (:require [clojure.test :refer :all] [project-checkup.core :refer :all])) -(deftest a-test - (testing "FIXME, I fail." - (is (= 0 1)))) + + +(deftest test-check-vcs + (testing "Ensure the check works." + (is + (check-vcs {:files [".git"]}) ) + (is + (check-vcs {:files [".hg"]}) ) + (is + (not (check-vcs {:files []})) ) + (is ;various almost-correct entries + (not (check-vcs {:files ["hg" "git" "."]})) ))) + + +(deftest test-check-readme + (testing "Ensure READMEs are found correctly." + (is + (check-readme {:files ["README.md"]}))) + (testing "Ensure no false positives" + (is + (not (check-readme {:files ["readme.exe"]}))) + (is + (not (check-readme {:files []}))))) + +(deftest test-check-untracked + (testing "Ensure empty returns true" + (is (check-untracked {:untracked-files []})) + ) + (testing "Ensure non-empty returns false" + (is (not (check-untracked {:untracked-files [".hg"]}))))) + + +(deftest test-get-extension + (testing "test various paths with extensions" + (is (= (get-extension "test.txt") ".txt")) + (is (= (get-extension "./test.txt") ".txt")) + (is (= (get-extension "test.txt.bak") ".bak")) + (is (= (get-extension ".hg/test.txt.bak") ".bak")) + ) + )