aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/clj/queue_api/test/db/core_test.clj71
1 files changed, 57 insertions, 14 deletions
diff --git a/test/clj/queue_api/test/db/core_test.clj b/test/clj/queue_api/test/db/core_test.clj
index a624319..d64b550 100644
--- a/test/clj/queue_api/test/db/core_test.clj
+++ b/test/clj/queue_api/test/db/core_test.clj
@@ -40,8 +40,8 @@
:job/date (time/date-time 2018 2 18 1 0 8)
:job/urgent true}
;;Agent that will be linked to jobs
- {:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d"
- :agent/name "Dummy Derp"
+ {:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d"
+ :agent/name "Dummy Derp"
:agent/primary-skillset ["rewards-question" "bills-question"]
:agent/secondary-skillset []}
;;Change job status to :completed and link agent
@@ -70,6 +70,12 @@
(d/transact! conn simple-schema)
(f)))
+(defn agent [id]
+ (d/entity @conn [:agent/id id]))
+
+(defn job [id]
+ (d/entity @conn [:job/id id]))
+
(deftest add-agent-test
(testing "Test adding agent"
(let [tx (add-agent {:id "1d7158f8-f7a0-4ff9-9758-25efcc5aae65"
@@ -111,26 +117,26 @@
(deftest q-job-test
(testing "test query job"
- (is (= [(d/entity @conn [:job/id "96cf6f11-591d-4cde-9ab0-56e371acb6d2"])
- (d/entity @conn [:job/id "51ab0771-f1e4-4268-868f-9029a58f6612"])]
+ (is (= [(job "96cf6f11-591d-4cde-9ab0-56e371acb6d2")
+ (job "51ab0771-f1e4-4268-868f-9029a58f6612")]
(q-job false :unassigned "rewards-question")))
- (is (= [(d/entity @conn [:job/id "b201d085-91b5-4a13-9a74-7861426e9996"])]
+ (is (= [(job "b201d085-91b5-4a13-9a74-7861426e9996")]
(q-job true :processing "purchases-question")))
- (is (= [(d/entity @conn [:job/id "aa327540-4e24-47f4-9e9c-81cdd5195934"])]
+ (is (= [(job "aa327540-4e24-47f4-9e9c-81cdd5195934")]
(q-job true :completed "bills-question")))
(is (= [] (q-job false :completed "rewards-question")))
- (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])]
+ (is (= [(job "1e0d939d-494b-48d2-9247-b5ae207a519a")]
(q-job false :completed "rewards-question" "bills-question")))
- (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])]
+ (is (= [(job "1e0d939d-494b-48d2-9247-b5ae207a519a")]
(q-job false :completed ["rewards-question" "bills-question"])))))
(deftest agent-jobs-test
(testing "Test fetch relation agent job"
- (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])
- (d/entity @conn [:job/id "aa327540-4e24-47f4-9e9c-81cdd5195934"])
- (d/entity @conn [:job/id "3cdc52fe-b538-40a6-a9d7-92fa840c2c4b"])]
+ (is (= [(job "1e0d939d-494b-48d2-9247-b5ae207a519a")
+ (job "aa327540-4e24-47f4-9e9c-81cdd5195934")
+ (job "3cdc52fe-b538-40a6-a9d7-92fa840c2c4b")]
(agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :completed)))
- (is (= [(d/entity @conn [:job/id "b201d085-91b5-4a13-9a74-7861426e9996"])]
+ (is (= [(job "b201d085-91b5-4a13-9a74-7861426e9996")]
(agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :processing)))
(is (= [] (agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :unassigned)))))
@@ -140,7 +146,44 @@
(sum-agent "644be0ce-035d-48cb-867e-8e6de2714a8d")))
(is (= [] (sum-agent "00000000-0000-0000-0000-000000000000")))))
+;;TODO:adicionar mais testes
(deftest request-job-test
(testing "test query for skillset"
- (is (= (d/entity @conn [:job/id "96cf6f11-591d-4cde-9ab0-56e371acb6d2"])
- (request-job "644be0ce-035d-48cb-867e-8e6de2714a8d"))))) \ No newline at end of file
+ (is (= (job "96cf6f11-591d-4cde-9ab0-56e371acb6d2")
+ (request-job "644be0ce-035d-48cb-867e-8e6de2714a8d")))))
+
+(deftest bind-agent-test
+ (testing "Test bind agent"
+ (let [_ (bind-agent "644be0ce-035d-48cb-867e-8e6de2714a8d" "51ab0771-f1e4-4268-868f-9029a58f6612")
+ a (agent "644be0ce-035d-48cb-867e-8e6de2714a8d")]
+ (is (= "51ab0771-f1e4-4268-868f-9029a58f6612"
+ (-> a :agent/job :job/id))))))
+
+(deftest t-job-test
+ (testing "Test transact job"
+ (let [_ (t-job "51ab0771-f1e4-4268-868f-9029a58f6612" :completed)
+ j (job "51ab0771-f1e4-4268-868f-9029a58f6612")]
+ (is (= :completed (:job/status j))))
+ (let [_ (t-job "51ab0771-f1e4-4268-868f-9029a58f6612" :completed "644be0ce-035d-48cb-867e-8e6de2714a8d")
+ j (job "51ab0771-f1e4-4268-868f-9029a58f6612")]
+ (are [left right]
+ (= left right)
+ :completed (:job/status j)
+ "644be0ce-035d-48cb-867e-8e6de2714a8d" (-> j :job/agent :agent/id)))))
+
+(deftest end-job-test
+ (testing "Test end job"
+ (let [a (agent "644be0ce-035d-48cb-867e-8e6de2714a8d")
+ _ (end-job a)]
+ (is (= :completed (-> (agent "644be0ce-035d-48cb-867e-8e6de2714a8d")
+ :agent/job :job/status))))))
+
+(deftest start-job-test
+ (testing "Test start a new job"
+ (let [_ (start-job "644be0ce-035d-48cb-867e-8e6de2714a8d" "96cf6f11-591d-4cde-9ab0-56e371acb6d2")
+ a (agent "644be0ce-035d-48cb-867e-8e6de2714a8d")]
+ (are [left right]
+ (= left right)
+ :processing (-> a :agent/job :job/status)
+ "96cf6f11-591d-4cde-9ab0-56e371acb6d2" (-> a :agent/job :job/id)))))
+