 (ns gh-waiting-room.github-test
   (:require [clojure.test :refer :all]
             tentacles.issues
+            gh-waiting-room.config
             [gh-waiting-room.github :as github :refer [->issue]]
             [echo.test.mock :refer [expect has-args times once]]))
 

    (is (= (:desc (->issue (assoc valid-gh-issue :body (str (apply str (repeat 98 "A")) " BBBB"))))
           (str (apply str (repeat 98 "A")) " ...")))))

(defn issue-with-name-and-private
  [name private]
  (-> valid-gh-issue
      (update-in [:repository :private] (constantly private))
      (update-in [:repository :name] (constantly name))))

(defn viewable-issues
  [db]

    (github/viewable-issues db)))

(deftest issue-filter-test
  (testing "filters out private and allows public and unspecified :private issues"
    (is (= (->> {:issues [(create-issue "faceplant-public" :private false)
                       valid-gh-issue
                       (create-issue "faceplant-private" :private true)]}
             viewable-issues
             (map :name))
           ["faceplant-public" "faceplant"])))
  
  (testing "filters out repositories with regular expression by default"
    (is (= (->> {:issues [valid-gh-issue
                          (create-issue "pedestal" :html_url "https://github.com/pedestal/pedestal/issues/27")
                          (create-issue "ripl-multi_line" :html_url "https://github.com/janlelis/ripl-multi_line/issues/27")]}
                (#(with-redefs [gh-waiting-room.config/gh-user (constantly "(cldwalker|janlelis)")]
                    (github/viewable-issues %)))
                (map :name))
           ["faceplant" "ripl-multi_line"])))
)

#_(deftest viewable-issues-test
  (testing "filters out issues with specific labels when $GITHUB_HIDE_LABELS set")
  (testing "filters out issues with labels by default") 
  (testing "sorts issues by coments and then created")
  (testing "adds :position by list order"))