diff --git a/.clj-kondo/src/hooks/metabase/api/common.clj b/.clj-kondo/src/hooks/metabase/api/common.clj index ad3e7556709eb01a57822318878ba965e9942cd0..187df91c6ec6642dd7b947789b2bb7fa4f520c68 100644 --- a/.clj-kondo/src/hooks/metabase/api/common.clj +++ b/.clj-kondo/src/hooks/metabase/api/common.clj @@ -19,29 +19,14 @@ (-> (api/list-node (list (api/token-node 'do) - (api/token-node (symbol "compojure.core" (str (api/sexpr method)))) - (-> (api/list-node - (list* - (api/token-node 'clojure.core/defn) - (api/token-node (route-fn-name (api/sexpr method) (api/sexpr route))) - body)) - (with-meta (meta node))))) + (-> (api/token-node (symbol "compojure.core" (str (api/sexpr method)))) + (with-meta (meta method))) + (api/list-node + (list* + (api/token-node 'clojure.core/defn) + (-> (api/token-node (route-fn-name (api/sexpr method) (api/sexpr route))) + (with-meta (meta route))) + body)))) + (with-meta (meta node)) hooks.common/add-lsp-ignore-unused-public-var-metadata)))] (update arg :node update-defendpoint))) - -(comment - (-> {:node (-> '(api/defendpoint POST "/:id/copy" - "Copy a `Card`, with the new name 'Copy of _name_'" - [id] - {id [:maybe ms/PositiveInt]} - (let [orig-card (api/read-check Card id) - new-name (str (trs "Copy of ") (:name orig-card)) - new-card (assoc orig-card :name new-name)] - (-> (card/create-card! new-card @api/*current-user*) - hydrate-card-details - (assoc :last-edit-info (last-edit/edit-information-for-user @api/*current-user*))))) - pr-str - api/parse-string)} - defendpoint - :node - api/sexpr)) diff --git a/.clj-kondo/test/hooks/metabase/api/common_test.clj b/.clj-kondo/test/hooks/metabase/api/common_test.clj new file mode 100644 index 0000000000000000000000000000000000000000..0402b5c13567f2a52d0c0d9a4eb2e9a32819801c --- /dev/null +++ b/.clj-kondo/test/hooks/metabase/api/common_test.clj @@ -0,0 +1,35 @@ +(ns hooks.metabase.api.common-test + (:require + [clj-kondo.hooks-api :as api] + [clojure.test :refer :all] + [hooks.metabase.api.common])) + +(deftest ^:parallel defendpoint-test + (is (= '(do + compojure.core/POST + (clojure.core/defn + POST_:id_copy + "Copy a `Card`, with the new name 'Copy of _name_'" + [id] + {id [:maybe ms/PositiveInt]} + (let [orig-card (api/read-check Card id) + new-name (str (trs "Copy of ") (:name orig-card)) + new-card (assoc orig-card :name new-name)] + (-> (card/create-card! new-card @api/*current-user*) + hydrate-card-details + (assoc :last-edit-info (last-edit/edit-information-for-user @api/*current-user*)))))) + (-> {:node (-> '(api/defendpoint POST "/:id/copy" + "Copy a `Card`, with the new name 'Copy of _name_'" + [id] + {id [:maybe ms/PositiveInt]} + (let [orig-card (api/read-check Card id) + new-name (str (trs "Copy of ") (:name orig-card)) + new-card (assoc orig-card :name new-name)] + (-> (card/create-card! new-card @api/*current-user*) + hydrate-card-details + (assoc :last-edit-info (last-edit/edit-information-for-user @api/*current-user*))))) + pr-str + api/parse-string)} + hooks.metabase.api.common/defendpoint + :node + api/sexpr))))