         headers => (contains {"Content-Type" "application/json"
                               "X-Samsara-publishedTimestamp" anything})
 
+        body => (to-json [{:eventName "a" :timestamp 1 :sourceId "d1"}] )
+
         )
       )
+
+
+(fact "publish-events: should post the given events to the ingestion-api"
+
+      ;; successful post of a single event
+      (with-mock-send-events
+        (publish-events "http://localhost:9000/v1"
+                        [{:invalid "event"}])
+        ) => (throws Exception)
+      )

(ns samsara.client-test
  (:require [samsara.client2 :refer :all]
            [midje.sweet :refer :all]))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;                                                                            ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defmacro with-mock-send-events [publish & body]
  `(with-redefs [samsara.client2/send-events (fn [& args#] args#)]
     (let [[~'url ~'headers ~'body ~'opts] ~publish]
