jackdaw

https://github.com/FundingCircle/jackdaw
Travis 2019-06-12T19:56:02.016700Z

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?

2019-06-12T20:20:08.029700Z

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.

Travis 2019-06-12T20:22:44.030Z

thanks! I will take a look

Travis 2019-06-12T20:32:15.030500Z

@cddr Where exactly is this version ?

2019-06-12T20:32:28.030700Z

Should be in clojars

Travis 2019-06-12T20:32:52.030900Z

ah yes I see it

Travis 2019-06-12T20:33:16.031100Z

thank you sir