Skip to content

Commit

Permalink
update-category-test
Browse files Browse the repository at this point in the history
  • Loading branch information
saidone75 committed Jul 16, 2024
1 parent 725a3ae commit 2f69240
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cral/api/core/categories.clj
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
(update-category ticket category-id body nil))
([^Ticket ticket ^String category-id ^UpdateCategoryBody body ^UpdateCategoryQueryParams query-params & [^PersistentHashMap opts]]
(utils/call-rest
client/post
client/put
(format "%s/categories/%s" (config/get-url 'core) category-id)
ticket
{:body (json/write-str (utils/camel-case-stringify-keys body))
Expand Down
14 changes: 14 additions & 0 deletions test/cral/categories_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@
created-category-id (get-in (categories/create-category ticket "-root-" (model/map->CreateCategoryBody {:name (.toString (UUID/randomUUID))})) [:body :entry :id])]
(is (= (:status (categories/delete-category ticket created-category-id)) 204))))

(deftest update-category-test
(let [ticket (get-in (auth/create-ticket c/user c/password) [:body :entry])
;; create category
created-category-entry (-> (categories/create-category ticket "-root-" (model/map->CreateCategoryBody {:name (.toString (UUID/randomUUID))}))
(get-in [:body :entry]))
;; update category
new-category-name (.toString (UUID/randomUUID))
updated-category-response (->> (model/map->UpdateCategoryBody {:name new-category-name})
(categories/update-category ticket (:id created-category-entry)))]
(is (= (:status updated-category-response) 200))
(is (= (get-in updated-category-response [:body :entry :name]) new-category-name))
;; clean up
(is (= (:status (categories/delete-category ticket (:id created-category-entry))) 204))))

(deftest list-categories-test
(let [ticket (get-in (auth/create-ticket c/user c/password) [:body :entry])]
;; list categories
Expand Down

0 comments on commit 2f69240

Please sign in to comment.