 
 (deftest controller-whitelist-test
   (let [response (promise)]
-    (with-redefs [server/on-connect (fn [_ ws] (websockets-client/send! ws (message/encode self-request)))
+    (with-redefs [server/on-connect (fn [_ ws]
+                    (try
+                      (websockets-client/send! ws (message/encode self-request))
+                      (catch Exception e (println "controller-whitelist-test exception:" (.getMessage e)))))
                   server/on-text (fn [_ ws text] (deliver response (message/decode text)))]
       (with-app-with-config app (conj broker-services server/mock-server) broker-config
         (let [answer (deref response 3000 nil)]

(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 [inventory-response (promise)
        inventory-update (atom (promise))]
    (with-redefs [puppetlabs.pcp.broker.inventory/batch-update-interval-ms 10
                  server/on-connect (fn [_ ws]
                    (try
                      (websockets-client/send! ws (message/encode inventory-subscribe))
                      (catch Exception e (println "controllers-subscribe exception:" (.getMessage e)))))
                  server/on-text (fn [_ ws text]
                    (let [msg (message/decode text)]
                      (case (:message_type msg)
