diff --git a/src/rss_thread_watch/utils.clj b/src/rss_thread_watch/utils.clj index 5d81d9b..0106301 100644 --- a/src/rss_thread_watch/utils.clj +++ b/src/rss_thread_watch/utils.clj @@ -47,10 +47,12 @@ ~x result#))) -(defmacro vectorize - "If arg is not a vector, put into vector, otherwise return it" +(defn vectorize + "If v isn't a vector, put it into one, otherwise return" [v] - (if (vector? v) v [v])) + (if (vector? v) + v + [v])) ;; ===== Generic functions ==== diff --git a/test/rss_thread_watch/feed_generator_test.clj b/test/rss_thread_watch/feed_generator_test.clj index 1cb2118..ab1cf3f 100644 --- a/test/rss_thread_watch/feed_generator_test.clj +++ b/test/rss_thread_watch/feed_generator_test.clj @@ -1,6 +1,7 @@ (ns rss-thread-watch.feed-generator-test (:require [clojure.test :refer :all] - [rss-thread-watch.feed-generator :refer :all])) + [rss-thread-watch.feed-generator :refer :all] + [rss-thread-watch.filters :as f])) (def thread-list [{:title "Some thread title" :chod 94.0 @@ -26,9 +27,17 @@ (is (= (update-only-guid sin-thrd) (assoc sin-thrd :guid "696942042-20-94.00")))))) +(def query-map1 {"Q" ["PONIes" "aRe" "CUTE"] + "q" ["/general/" "foo bar"] + "x" "Not really filter" + "board" ["/p/" "/mlp/"]}) + +(def query-map1-result {f/case-insensitive-filter ["/general/" "foo bar"] + f/case-sensitive-filter ["PONIes" "aRe" "CUTE"]}) + (deftest filtering - (testing "Filter map making") - ) + (testing "Filter map making" + (is (= query-map1-result (make-filters query-map1 f/known-filters)))))