From 14aa8e3e8dc0994b3891a67fab4099a3224e41c4 Mon Sep 17 00:00:00 2001 From: seki Date: Fri, 23 Dec 2016 03:17:21 +0900 Subject: [PATCH] Make it return 404 when client execute not exist job --- .../job_streamer/control_bus/component/jobs.clj | 1 + .../control_bus/component/jobs_test.clj | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/clj/job_streamer/control_bus/component/jobs.clj b/src/clj/job_streamer/control_bus/component/jobs.clj index b121ea8..9fd7f3d 100644 --- a/src/clj/job_streamer/control_bus/component/jobs.clj +++ b/src/clj/job_streamer/control_bus/component/jobs.clj @@ -633,6 +633,7 @@ (not (:job/exclusive? (:job ctx))))) :put-to-existing? (fn [ctx] (#{:put :post} (get-in ctx [:request :request-method]))) + :post-to-missing? (fn [ctx] (find-by-name jobs app-name job-name)) :conflict? (fn [{job :job}] (if-let [last-execution (some->> (:job/executions job) (sort #(compare (:job-execution/create-time %2) (:job-execution/create-time %1))) diff --git a/test/clj/job_streamer/control_bus/component/jobs_test.clj b/test/clj/job_streamer/control_bus/component/jobs_test.clj index 1e05686..8926d5d 100644 --- a/test/clj/job_streamer/control_bus/component/jobs_test.clj +++ b/test/clj/job_streamer/control_bus/component/jobs_test.clj @@ -355,10 +355,16 @@ :step-execution-id 11111111111111}]}) (is (= "SUCCESS" (-> request handler :body read-string :job-execution/step-executions first :step-execution/exit-status))))))) - - - - +(deftest executions-resource + (let [system (new-system config)] + ;; setup data + ((-> (jobs/list-resource (:jobs system) "default")) {:request-method :post + :content-type "application/edn" + :body (pr-str {:job/name "job1"})}) + (testing "return 404 when job-name is not exist" + (let [handler (-> (jobs/executions-resource (:jobs system) "default" "job2")) + request {:request-method :post}] + (is (= 404 (-> request handler :status))))))) (deftest parse-query (testing "parse-query"