This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GH-1356] Fix Coercion Failure for TDR Snapshots Source (#429)
RR: https://broadinstitute.atlassian.net/browse/GH-1356 Caused by metosin/reitit#494 Fix as per https://broadinstitute.atlassian.net/browse/GH-1348 Included integration test for reitit coercions to catch this sooner.
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
(:require [clojure.test :refer :all] | ||
[clojure.spec.alpha :as s] | ||
[clojure.string :as str] | ||
[reitit.coercion.spec] | ||
[reitit.ring :as ring] | ||
[reitit.ring.coercion :as coercion] | ||
[wfl.api.spec :as spec] | ||
[wfl.api.spec :as spec] | ||
[wfl.integration.modules.shared :as shared] | ||
[wfl.jdbc :as jdbc] | ||
|
@@ -643,3 +647,47 @@ | |
{:skipValidation true} | ||
{:skipValidation true} | ||
{:skipValidation true})))) | ||
|
||
(defn ^:private create-app [input-spec output-spec handler] | ||
(let [app | ||
(ring/ring-handler | ||
(ring/router | ||
[["/test" {:post {:parameters {:body input-spec} | ||
:responses {200 {:body output-spec}} | ||
:handler (fn [{:keys [body-params]}] | ||
{:status 200 | ||
:body (handler body-params)})}}]] | ||
{:data {:coercion reitit.coercion.spec/coercion | ||
:middleware [coercion/coerce-exceptions-middleware | ||
coercion/coerce-request-middleware | ||
coercion/coerce-response-middleware]}}))] | ||
(fn [request] | ||
(app {:request-method :post | ||
:uri "/test" | ||
:body-params request})))) | ||
|
||
(deftest test-create-workload-coercion | ||
(let [app (create-app ::spec/workload-request | ||
::spec/workload-response | ||
(comp util/to-edn workloads/create-workload!)) | ||
request (workloads/covid-workload-request | ||
{} | ||
{:skipValidation true} | ||
{:skipValidation true})] | ||
(testing "Workload with a TDR Source" | ||
(let [{:keys [status body]} | ||
(->> {:name "Terra DataRepo" | ||
:dataset testing-dataset | ||
:table testing-table-name | ||
:column testing-column-name | ||
:snapshotReaders ["[email protected]"]} | ||
(assoc request :source) | ||
app)] | ||
(is (== 200 status) body))) | ||
(testing "Workload with a TDR Snapshots Source" | ||
(let [{:keys [status body]} | ||
(->> {:name "TDR Snapshots" | ||
:snapshots [testing-snapshot]} | ||
(assoc request :source) | ||
app)] | ||
(is (== 200 status) body))))) |