Skip to content

Commit

Permalink
Show type in status (#279)
Browse files Browse the repository at this point in the history
* Show type in status

* Renamed type to action
  • Loading branch information
mdemare authored Feb 9, 2024
1 parent c7c33c9 commit 84e0928
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/nl/surf/eduhub_rio_mapper/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions test/nl/surf/eduhub_rio_mapper/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -274,6 +276,7 @@
:phase "middle"}})

(status-set! {:token "test-done"
:action "delete"
::ooapi/type "test"
::ooapi/id "31415"}
:done
Expand Down Expand Up @@ -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"})))
Expand All @@ -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"}}}
Expand All @@ -319,6 +324,7 @@
:status http-status/ok
:body {:status :error
:token "test-error"
:action "link"
:resource "test/3141"
:phase "middle"
:message "error"}}
Expand Down
2 changes: 2 additions & 0 deletions test/nl/surf/eduhub_rio_mapper/job_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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"}
Expand Down

0 comments on commit 84e0928

Please sign in to comment.