From 64773838cb5c177994a7d86b557ea464fa06dcd2 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 17 Feb 2018 22:41:00 -0200 Subject: Adds test for service.clj --- test/clj/queue_api/test/handler.clj | 42 ++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'test/clj') diff --git a/test/clj/queue_api/test/handler.clj b/test/clj/queue_api/test/handler.clj index 1aceb3c..aa0dfa1 100644 --- a/test/clj/queue_api/test/handler.clj +++ b/test/clj/queue_api/test/handler.clj @@ -8,14 +8,46 @@ :once (fn [f] (mount/start #'queue-api.config/env - #'queue-api.handler/app) + #'queue-api.handler/app + #'queue-api.db.core/conn) + (f))) -(deftest test-app - (testing "main route" - (let [response (app (request :get "/"))] - (is (= 200 (:status response))))) +(deftest agent-test + (testing "Agent route" + (let [response (-> (request :put "/agent") + (json-body {:id "8ab86c18-3fae-4804-bfd9-c3d6e8f66260" + :name "Dummy" + :primary_skillset ["reward_request"] + :secondary_skillset []}) + app)] + (is (= 200 (:status response)))) + (let [response (-> (request :post "/agent") + (json-body {:agent_id "8ab86c18-3fae-4804-bfd9-c3d6e8f66260"}) + app)] + (is (= 200 (:status response)))))) + +(deftest job-test + (testing "Job route" + (let [response (-> (request :put "/job") + (json-body {:id "895e9b31-5690-486e-b8dd-5c2345e056f6" + :type "bills_request" + :urgent false}) + app)] + (is (= 200 (:status response)))) + (let [response (-> (request :post "/job") + (json-body {:agent_id "8ab86c18-3fae-4804-bfd9-c3d6e8f66260"}) + app)] + (is (= 200 (:status response)))))) + +(deftest queue-test + (testing "Queue route" + (let [response (app (request :get "/queue"))] + (is (= 200 (:status response)))))) + +(deftest queue "/queue") +(deftest invalid-test (testing "not-found route" (let [response (app (request :get "/invalid"))] (is (= 404 (:status response)))))) -- cgit v1.2.3