 (deftest controller-agent-connected-test
   (let [inventory-response (promise)
         agent-response (promise)]
-    (with-redefs [server/on-connect (fn [_ ws] (websockets-client/send! ws (message/encode inventory-request)))
+    (with-redefs [server/on-connect (fn [_ ws]
+                    (try
+                      (websockets-client/send! ws (message/encode inventory-request))
+                      (catch Exception e (println "controller-agent-connected-test exception:" (.getMessage e)))))
                   server/on-text (fn [_ ws text]
                     (let [msg (message/decode text)]
                       (if (= (:message_type msg) "http://puppetlabs.com/inventory_response")

(deftest controller-no-agent-test
  (let [response1 (promise)
        response2 (promise)]
    (with-redefs [server/on-connect (fn [_ ws] (websockets-client/send! ws (message/encode inventory-request)))
                  server/on-text (fn [_ ws text]
                    (if-not (realized? response1)
                      (do

  (let [responses {:mock-server-1 [(promise) (promise)]
                   :mock-server-2 [(promise) (promise)]
                   :mock-server-3 [(promise) (promise)]}]
    (with-redefs [server/on-connect (fn [_ ws]
                    (try
                      (websockets-client/send! ws (message/encode inventory-request))
                      (catch Exception e (println "multiple-controllers-test exception:" (.getMessage e)))))
                  server/on-text (fn [server ws text]
                    (let [[response1 response2] (get responses server)]
                      (if-not (realized? response1)
