Hi guys, I have been playing around with the Test Machine stuff ( pretty cool so far ). One thing I am trying to understand how to do is something that just tests consuming. For instance, I have a rest service that takes data and puts it on a topic. Could I use the Test Machine to consume from that topic and verify the data exists with the right keys and such? One thing I am not clear on is if it is possible where would I put the REST call so that the consumer is ready to receive the data?
Hey @camechis,
Good question! I haven't had to do anything like that yet but I think if I did, I'd probably try using the new :do!
command (available in "0.6.5-test_machine_do_with_machine-SNAPSHOT") to represent the requests.
The strategy being, use the :do!
command to
- instigate the request against your REST service
- log the request and/or response in the journal
- then use a subsequent :watch
command that uses the content of the journal to determine when the expected data has been written to kafka
The :do!
command makes the journal available as an atom so your helper functions would look something like this.
(defn log-http-post [journal http-result]
(update-in journal [:http-results] concat http-result))
(defn rest-post-fn [url params]
(fn [journal]
(send journal log-http-post (http/post url params))))
and then the command that uses them would be something like
[:do! (rest-post-fn "<http://my.cool.service>" {:id 1, :type "foo" :payload "yolo"})]
[:watch (fn [journal]
(foo-exists? journal {:id 1}))]
Hope that gets the idea across. Give me a shout if you run into any difficulties.thanks! I will take a look
@cddr Where exactly is this version ?
Should be in clojars
ah yes I see it
thank you sir