Skip to content

Commit

Permalink
Merge pull request #46 from saidone75/dev
Browse files Browse the repository at this point in the history
better pipe tests
  • Loading branch information
saidone75 authored May 21, 2024
2 parents 431be92 + 85e2b2b commit 6762270
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/weller/components/activemq_listener.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
(try
(.close connection)
(catch Throwable _
(t/log! :warn (format "error while stopping " component-name))))
(t/log! :warn (format "error while stopping %s" component-name))))
(assoc this :connection nil)))))

(defn make-listener
"Creates an ActiveMQ listener with configuration data specified in `config`, received messages will be put in `chan`."
"Creates an ActiveMQ listener with configuration map `config`. Received messages will be put in `chan`."
[config chan]
(map->ActiveMqListener {:config config
:connection nil
Expand Down
2 changes: 1 addition & 1 deletion src/weller/pipe.clj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
(assoc this :taps (conj (:taps this) (mh/make-handler (pred/make-tap (:mult this) pred) f)))))

(defn remove-taps
"Stop the pipe and remove all taps from it."
"Stop the pipe if running and remove all taps from it."
[this]
(if (:running this)
(assoc (component/stop this) :taps [])
Expand Down
2 changes: 1 addition & 1 deletion test/weller/fixtures.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
(c/configure)
;; configure CRAL
(cral.config/configure (:alfresco @c/config))
;; put an Alfresco ticket in config atom for tests
;; put an Alfresco ticket in config atom later use
(swap! c/config assoc :ticket (get-in (auth/create-ticket (get-in @c/config [:alfresco :user]) (get-in @c/config [:alfresco :password])) [:body :entry]))
(f))
26 changes: 13 additions & 13 deletions test/weller/pipe_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,44 @@
(ns weller.pipe-test
(:require [clojure.test :refer :all]
[cral.api.core.nodes :as nodes]
[taoensso.telemere :as t]
[weller.components.component :as component]
[weller.config :as c]
[weller.events :as events]
[weller.fixtures :as fixtures]
[weller.pipe :as pipe]
[weller.predicates :as pred]
[weller.test-utils :as tu]))
[weller.test-utils :as tu])
(:import (java.util UUID)))

(use-fixtures :once fixtures/ticket)

(def ^:const node-name "test node name")

(defn- get-node-name-with-cral
[resource]
(get-in (nodes/get-node (:ticket @c/config) (:id resource)) [:body :entry :name]))

(deftest make-pipe-test
(let [result (promise)
pipe (pipe/make-pipe)
pipe (pipe/add-filtered-tap pipe (pred/event? events/node-created) #(deliver result (get-node-name-with-cral %)))]
(component/start pipe)
pipe (-> (pipe/make-pipe)
(pipe/add-filtered-tap (pred/event? events/node-created) #(deliver result (get-node-name-with-cral %)))
(component/start))
node-name (.toString (UUID/randomUUID))]
(tu/create-then-update-then-delete-node node-name)
(t/log! @result)
(is (= @result node-name))
(component/stop pipe)))

(deftest simple-make-pipe-test
(let [result (promise)
;; note that pipe is started automatically with this constructor
pipe (pipe/make-pipe (pred/event? events/node-created) #(deliver result (get-node-name-with-cral %)))]
pipe (pipe/make-pipe (pred/event? events/node-created) #(deliver result (get-node-name-with-cral %)))
node-name (.toString (UUID/randomUUID))]
(tu/create-then-update-then-delete-node node-name)
(t/log! @result)
(is (= @result node-name))
(component/stop pipe)))

(deftest simple-make-pipe-double-start-double-stop-test
(let [pipe (pipe/make-pipe (pred/event? events/node-created) nil)
pipe (component/start pipe)
pipe (component/stop pipe)]
(let [pipe (-> (pipe/make-pipe (pred/event? events/node-created) nil)
(component/start)
(component/stop))]
(component/stop pipe)))

(deftest remove-then-add-tap-test
Expand Down

0 comments on commit 6762270

Please sign in to comment.