From 84e092887527ded6c9d6b525aba479d036582cd2 Mon Sep 17 00:00:00 2001 From: Michiel de Mare Date: Fri, 9 Feb 2024 11:21:34 +0100 Subject: [PATCH] Show type in status (#279) * Show type in status * Renamed type to action --- src/nl/surf/eduhub_rio_mapper/cli.clj | 3 ++- test/nl/surf/eduhub_rio_mapper/api_test.clj | 6 ++++++ test/nl/surf/eduhub_rio_mapper/job_test.clj | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/nl/surf/eduhub_rio_mapper/cli.clj b/src/nl/surf/eduhub_rio_mapper/cli.clj index 4f572d47..cb2a639c 100644 --- a/src/nl/surf/eduhub_rio_mapper/cli.clj +++ b/src/nl/surf/eduhub_rio_mapper/cli.clj @@ -233,12 +233,13 @@ (logging/log-exception ex nil)))))))) (defn make-set-status-fn [config] - (fn [{::job/keys [callback-url] :keys [token] ::ooapi/keys [id type] :as job} + (fn [{::job/keys [callback-url] :keys [token action] ::ooapi/keys [id type] :as job} status & [data]] (let [opleidingseenheidcode (-> data :aanleveren_opleidingseenheid_response :opleidingseenheidcode) aangeb-opleidingcode (-> data ::rio/aangeboden-opleiding-code) value (cond-> {:status status :token token + :action action :resource (str type "/" id)} (and (= :done status) diff --git a/test/nl/surf/eduhub_rio_mapper/api_test.clj b/test/nl/surf/eduhub_rio_mapper/api_test.clj index bd910ae1..27fd32a3 100644 --- a/test/nl/surf/eduhub_rio_mapper/api_test.clj +++ b/test/nl/surf/eduhub_rio_mapper/api_test.clj @@ -260,11 +260,13 @@ (status/purge! config) (status-set! {:token "test-pending" + :action "upsert" ::ooapi/type "test" ::ooapi/id "314"} :pending) (status-set! {:token "test-error" + :action "link" ::ooapi/type "test" ::ooapi/id "3141"} :error @@ -274,6 +276,7 @@ :phase "middle"}}) (status-set! {:token "test-done" + :action "delete" ::ooapi/type "test" ::ooapi/id "31415"} :done @@ -301,6 +304,7 @@ (is (= {:token "test-pending" :status http-status/ok :body {:status :pending + :action "upsert" :token "test-pending" :resource "test/314"}} (app {:token "test-pending"}))) @@ -309,6 +313,7 @@ (is (= {:token "test-done" :status http-status/ok :body {:status :done + :action "delete" :token "test-done" :resource "test/31415" :attributes {:opleidingseenheidcode "code"}}} @@ -319,6 +324,7 @@ :status http-status/ok :body {:status :error :token "test-error" + :action "link" :resource "test/3141" :phase "middle" :message "error"}} diff --git a/test/nl/surf/eduhub_rio_mapper/job_test.clj b/test/nl/surf/eduhub_rio_mapper/job_test.clj index f119ab88..360ca043 100644 --- a/test/nl/surf/eduhub_rio_mapper/job_test.clj +++ b/test/nl/surf/eduhub_rio_mapper/job_test.clj @@ -58,6 +58,7 @@ (let [last-seen-request-atom (atom nil) set-status-fn (cli/make-set-status-fn config) job {::job/callback-url "https://github.com/" + :action "delete" ::ooapi/type "course" ::ooapi/id "123123" :token "12345"} @@ -71,6 +72,7 @@ (helper/wait-while-predicate nil? last-seen-request-atom 1) (let [req @last-seen-request-atom] (is (= {:status "done" + :action "delete" :resource "course/123123" :attributes {:opleidingseenheidcode "123"} :token "12345"}