 (ns workflo.macros.command-test
   (:require [clojure.spec :as s]
             [clojure.test :refer [deftest is]]
-            [workflo.macros.command :refer [defcommand]]))
+            [workflo.macros.command :as c :refer [defcommand]]))
 
 (deftest minimal-defcommand
   (is (= '(do
             (defn user-create-implementation
               [query-result data]
               :foo :bar)
+            (def user-create-data-spec
+              vector?)
             (def user-create-definition
-              {:implementation pod/user-create-implementation}))
-         (macroexpand-1 `(defcommand user/create [vector?]
+              {:data-spec pod/user-create-data-spec
+               :implementation pod/user-create-implementation}))
+         (macroexpand-1 `(defcommand user/create [~'vector?]
                            ~'(:foo :bar))))))
 
 (deftest defcommand-with-cache-query

              (let [{:keys [db/id]} query-result]
                :result))
            (def user-create-cache-query
              [{:name db/id :type :property}])
            (def user-create-definition
              {:workflows pod/user-create-workflows
               :lifecycles pod/user-create-lifecycles
               :implementation pod/user-create-implementation
               :cache-query pod/user-create-cache-query}))
         (macroexpand-1 `(defcommand user/create [~'[db [id]] map?]
                           (~'workflows [:foo])
                           (~'lifecycles [:bar])
                           (:result))))))

              (let [{:keys [user/name user/email]} query-result]
                {:some :data}))
            (def user-update-cache-query
              '[{:name user/name :type :property}
                {:name user/email :type :property}])
            (def user-update-data-spec
              vector?)
            (def user-update-definition
              {:data-spec pod/user-update-data-spec
               :cache-query pod/user-update-cache-query
               :implementation pod/user-update-implementation}))
         (macroexpand-1 `(defcommand user/update [~'[user [name email]]
                                                  ~'vector?]
                           ({:some :data}))))))

(deftest defcommand-with-forms
  (is (= '(do
            (defn user-update-foo
              [query-result data]
              [:bar])
            (defn user-update-implementation
              [query-result data]
              {:implementation :result})
            (def user-update-data-spec
              vector?)
            (def user-update-definition
              {:foo pod/user-update-foo
               :implementation pod/user-update-implementation
               :data-spec pod/user-update-data-spec}))
         (macroexpand-1 `(defcommand user/update [~'vector?]
                           (~'foo [:bar])
                           ({:implementation :result}))))))

(deftest defcommand-with-cache-query-and-forms
  (is (= '(do
            (defn user-create-foo
              [query-result data]
              (let [{:keys [db/id]} query-result]
                [:bar]))
