From b31417fecc71d36acb725a6c3ec4f3bd2d3eb30c Mon Sep 17 00:00:00 2001 From: felisp Date: Tue, 22 Oct 2024 01:58:59 +0200 Subject: [PATCH] Add test for feed-generator/make-filters, change vectorize to function --- src/rss_thread_watch/utils.clj | 8 +++++--- test/rss_thread_watch/feed_generator_test.clj | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) 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)))))