aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2018-02-18 02:21:05 -0300
committerGabriel A. Giovanini <mail@gabrielgio.me>2018-02-18 02:21:05 -0300
commita17538127a37d480cd6efd6d3c44faab4a0a7f76 (patch)
tree217f917029e079fa0240b3a7df60f91f61bc6d5c /test
parent65357035e6fee399993da80d6d26aa833979cfcf (diff)
downloadqueue-api-a17538127a37d480cd6efd6d3c44faab4a0a7f76.tar.gz
queue-api-a17538127a37d480cd6efd6d3c44faab4a0a7f76.tar.bz2
queue-api-a17538127a37d480cd6efd6d3c44faab4a0a7f76.zip
Adds some functions to manage the queue
Diffstat (limited to 'test')
-rw-r--r--test/clj/queue_api/test/db/core_test.clj47
1 files changed, 36 insertions, 11 deletions
diff --git a/test/clj/queue_api/test/db/core_test.clj b/test/clj/queue_api/test/db/core_test.clj
index 4c30ed3..7abdd56 100644
--- a/test/clj/queue_api/test/db/core_test.clj
+++ b/test/clj/queue_api/test/db/core_test.clj
@@ -4,26 +4,30 @@
[queue-api.db.core :refer :all]
[datascript.core :as d]
[clj-time.core :as time]
- [mount.core :as mount])
- (:import (java.util UUID)))
+ [mount.core :as mount]))
(def simple-schema [;;Job that will be kept :unassigned
{:job/id "51ab0771-f1e4-4268-868f-9029a58f6612"
- :type "rewards-question"
+ :job/type "rewards-question"
:job/status :unassigned
- :job/date (time/now)
+ :job/date (time/date-time 2018 2 18 1 0 2)
+ :job/urgent false}
+ {:job/id "96cf6f11-591d-4cde-9ab0-56e371acb6d2"
+ :job/type "rewards-question"
+ :job/status :unassigned
+ :job/date (time/date-time 2018 2 18 1 0 1)
:job/urgent false}
;;Job that will be changed to processing
{:job/id "b201d085-91b5-4a13-9a74-7861426e9996"
- :type "rewards-question"
+ :job/type "purchases-question"
:job/status :unassigned
- :job/date (time/now)
+ :job/date (time/date-time 2018 2 18 1 0 4)
:job/urgent true}
;;Job that will be changed to completed
{:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"
- :type "rewards-question"
+ :job/type "bills-question"
:job/status :unassigned
- :job/date (time/now)
+ :job/date (time/date-time 2018 2 18 1 0 3)
:job/urgent true}
;;Agent that will be linked to jobs
{:agent/id "644be0ce-035d-48cb-867e-8e6de2714a8d"
@@ -71,7 +75,8 @@
(testing "test query job by status"
(are [left right]
(= left right)
- #{["51ab0771-f1e4-4268-868f-9029a58f6612"]} (q-status :unassigned)
+ #{["51ab0771-f1e4-4268-868f-9029a58f6612"]
+ ["96cf6f11-591d-4cde-9ab0-56e371acb6d2"]} (q-status :unassigned)
#{["1e0d939d-494b-48d2-9247-b5ae207a519a"]} (q-status :completed)
#{["b201d085-91b5-4a13-9a74-7861426e9996"]} (q-status :processing)
#{} (q-status :nil))))
@@ -80,5 +85,25 @@
(testing "test get summary of current state of the queue"
(is (= {:completed ["1e0d939d-494b-48d2-9247-b5ae207a519a"]
:processing ["b201d085-91b5-4a13-9a74-7861426e9996"]
- :unassigned ["51ab0771-f1e4-4268-868f-9029a58f6612"]}
- (sum-queue))))) \ No newline at end of file
+ :unassigned ["96cf6f11-591d-4cde-9ab0-56e371acb6d2"
+ "51ab0771-f1e4-4268-868f-9029a58f6612"]}
+ (sum-queue)))))
+
+(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"])]
+ (q-job false :unassigned "rewards-question")))
+ (is (= [(d/entity @conn [:job/id "b201d085-91b5-4a13-9a74-7861426e9996"])]
+ (q-job true :processing "purchases-question")))
+ (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])]
+ (q-job true :completed "bills-question")))
+ (is (= [] (q-job false :completed "rewards-question")))))
+
+(deftest agent-jobs-test
+ (testing "Test fetch relation agent job"
+ (is (= [(d/entity @conn [:job/id "1e0d939d-494b-48d2-9247-b5ae207a519a"])]
+ (agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :completed)))
+ (is (= [(d/entity @conn [:job/id "b201d085-91b5-4a13-9a74-7861426e9996"])]
+ (agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :processing)))
+ (is (= [] (agent-jobs "644be0ce-035d-48cb-867e-8e6de2714a8d" :unassigned))))) \ No newline at end of file