             [dk.ative.docjure.spreadsheet
              :refer
              [load-workbook read-cell row-seq select-sheet sheet-seq]]
-            [json-path :refer [at-path]])
+            [json-path :refer [at-path]]
+            [clojure.set :as set])
   (:import [clojure.data.xml CData Element]
            clojure.lang.ExceptionInfo
            java.lang.Integer

        (send-off a exec-test))
      @p)
    (map deref test-agents)))

(defn summarise-results [tests]
  (let [result-keys {:error 0 :failure 0 :success 0 :skipped 0 :ignored 0 :total 0}

                        nil)])])])
              out))))

(defn tests->postman [name tests opts]
  (let [all-placeholders (into #{} (reduce #(concat %1 (:placeholders %2)) [] tests))
        all-extractions (into #{} (reduce #(concat %1 (:extractions %2)) [] tests))
        all-suites (suites tests)]
    {:info {:name name :schema "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"}
     :variables (for [v (set/difference all-placeholders all-extractions)] {:id v :name v})
     :item (for [{:keys [name tests]} suites]
             {:name name
              :item (for [t tests]
                      {:name (:test t)
                       :request {:url (:url t)
                                 :method (:verb t)
                                 :header (for [[k v] (str->map (:headers t) #":" {} false)]
                                           {:key k :value v})
                                 :body (:payload t)}
                       :event (conj (for [[name path] (:extractions t)]
                                      {:list "test"
                                       :script (format "var resp=JSON.parse(responseBody);
postman.setEnvironmentVariable(\"%s\", %s);
" name (jsonpath->js path))})
                                    {:listen "test"
                                     :script (format "tests[\"Status code is %1$s\"] = responseCode.code === %1$s;" (:exp-status t))})})})}))

(defn- to-opts [args]
  (apply hash-map (map-indexed #(if (even? %1) (subs %2 1) %2) args)))

