restore test for 'replacements'
and add description in the README
This commit is contained in:
parent
09046c0dee
commit
560148efda
4 changed files with 39 additions and 18 deletions
|
@ -67,8 +67,12 @@ with later timestamps to avoid duplicate posts. On the first run the timestamp w
|
|||
;; optional keyword filter regexes
|
||||
;; any posts not matching the regexes will be filtered out
|
||||
:keyword-filters [".*clojure.*"]
|
||||
;; TODO: Description & example missing here
|
||||
:replacements nil}
|
||||
;; optional replacements
|
||||
;; When the strings on the left side of this map are encountered in the source,
|
||||
;; they are replaced with the string on the right side of the map:
|
||||
:replacements {
|
||||
"@openSUSE" "@opensuse@fosstodon.org",
|
||||
"@conservancy" "@conservancy@mastodon.technology"}}
|
||||
|
||||
{:source {:source-type :rss
|
||||
;; add RSS config to follow feeds
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#!/usr/bin/env lumo
|
||||
|
||||
(ns mastodon-bot.core_test
|
||||
(ns mastodon-bot.core-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [deftest is testing run-tests]]
|
||||
[cljs.reader :as edn]
|
||||
|
@ -25,14 +23,3 @@
|
|||
;; "Daar is 'ie dan! SPAMSPAMSPAM editie 2! Met een samenvatting van wat er in deze eerste twee maanden van 2020 gebeurd en gedaan is binnen @hack42. Lees het via: \nhttps://t.co/O1YzlWTFU3 #hackerspace #nieuws #arnhem #nuarnhem"
|
||||
;; (:text (core/parse-tweet (readfile "testdata/twitter/normal-tweet.edn")))
|
||||
;; )))
|
||||
|
||||
;; (deftest test-replacements
|
||||
;; (is (=
|
||||
;; "💠 Check out what has been going on during March in the world of @ReproBuilds! 💠 https://t.co/k6NsSO115z @opensuse@fosstodon.org @conservancy@mastodon.technology @PrototypeFund@mastodon.social @debian@fosstodon.org "
|
||||
;; (:text (core/perform-replacements (core/parse-tweet (readfile "testdata/twitter/tweet-mentions.edn"))))
|
||||
;; )))
|
||||
|
||||
(cljs.test/run-tests)
|
||||
|
||||
; Don't run core's -main when testing
|
||||
(set! *main-cli-fn* ())
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
(:require
|
||||
[cljs.test :refer-macros [deftest is testing run-tests]]
|
||||
[clojure.spec.alpha :as s]
|
||||
[cljs.reader :as edn]
|
||||
["fs" :as fs]
|
||||
[mastodon-bot.core :as core]
|
||||
[mastodon-bot.twitter-api :as twitter]
|
||||
[mastodon-bot.transform :as sut]
|
||||
))
|
||||
|
||||
|
@ -24,3 +28,14 @@
|
|||
:resolve-urls? true
|
||||
:content-filters [".*bannedsite.*"]
|
||||
:keyword-filters [".*"]}])))
|
||||
|
||||
(defn readfile [filename]
|
||||
(-> filename (fs/readFileSync #js {:encoding "UTF-8"}) edn/read-string))
|
||||
|
||||
(def testconfig (readfile "test.edn"))
|
||||
|
||||
(deftest test-replacements
|
||||
(is (=
|
||||
"💠 Check out what has been going on during March in the world of @ReproBuilds! 💠 https://t.co/k6NsSO115z @opensuse@fosstodon.org @conservancy@mastodon.technology @PrototypeFund@mastodon.social @debian@fosstodon.org "
|
||||
(:text (sut/perform-replacements (first (:transform testconfig)) (twitter/parse-tweet (readfile "testdata/twitter/tweet-mentions.edn"))))
|
||||
)))
|
19
test.edn
19
test.edn
|
@ -47,8 +47,23 @@
|
|||
;; optional keyword filter regexes
|
||||
;; any posts not matching the regexes will be filtered out
|
||||
:keyword-filters [".*clojure.*"]
|
||||
;; TODO: Description & example missing here
|
||||
:replacements nil}
|
||||
;; optional replacements
|
||||
;; When the strings on the left side of this map are encountered in the source,
|
||||
;; they are replaced with the string on the right side of the map:
|
||||
:replacements {
|
||||
"@openSUSE " "@opensuse@fosstodon.org ",
|
||||
"@archlinux " "",
|
||||
"@lolamby " "",
|
||||
"@conservancy " "@conservancy@mastodon.technology ",
|
||||
"@prototypefund " "@PrototypeFund@mastodon.social ",
|
||||
"@coreboot_org " "",
|
||||
"@OpenTechFund " "",
|
||||
"@OpenWrtSummit " "",
|
||||
"@OpenMirage " "",
|
||||
"@debian " "@debian@fosstodon.org ",
|
||||
"@nixos_org " "",
|
||||
"@lwnnet " "",
|
||||
"@guixhpc" ""}}
|
||||
|
||||
{:source {:source-type :rss
|
||||
;; add RSS config to follow feeds
|
||||
|
|
Reference in a new issue