Skip to content

Commit

Permalink
Merge pull request #664 from metosin/fix-swagger-tests
Browse files Browse the repository at this point in the history
Fix: swagger tests and CI
  • Loading branch information
mvarela authored Feb 9, 2024
2 parents 989ab72 + 82c714d commit 98f3eb0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
uses: DeLaGuardo/[email protected]
with:
lein: 2.9.5
- name: Install dependencies
run: |
npm ci
- name: Run tests
run: ./scripts/test.sh clj

Expand Down
12 changes: 7 additions & 5 deletions test/cljc/reitit/ring_coercion_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,14 @@
:uri "/foo"
:muuntaja/request {:format request-format}
:muuntaja/response {:format response-format}
:body-params body})]
:body-params body})
normalize-json (fn[body]
(-> body j/write-value-as-string (j/read-value j/keyword-keys-object-mapper)))]
(testing "succesful call"
(is (= {:status 200 :body {:request :json, :response :json}}
(call (request "application/json" "application/json" {:request :json :response :json}))))
(is (= {:status 200 :body {:request :edn, :response :json}}
(call (request "application/edn" "application/json" {:request :edn :response :json}))))
(is (= {:status 200 :body {:request "json", :response "json"}}
(normalize-json (call (request "application/json" "application/json" {:request :json :response :json})))))
(is (= {:status 200 :body {:request "edn", :response "json"}}
(normalize-json (call (request "application/edn" "application/json" {:request :edn :response :json})))))
(is (= {:status 200 :body {:request :default, :response :default}}
(call (request "application/transit" "application/transit" {:request :default :response :default})))))
(testing "request validation fails"
Expand Down
8 changes: 4 additions & 4 deletions test/cljc/reitit/swagger_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@
expected {:x-id #{::math}
:swagger "2.0"
:info {:title "my-api"}
:definitions {::req-key {:type "string"
:definitions {"reitit.swagger-test/req-key" {:type "string"
:x-anyOf [{:type "string"}
{:type "string"}]}
::req-val {:type "object"
"reitit.swagger-test/req-val" {:type "object"
:x-anyOf [{:type "object"}
{:type "string"}]}
::resp-map {:type "object"},
::resp-string {:type "string"
"reitit.swagger-test/resp-map" {:type "object"},
"reitit.swagger-test/resp-string" {:type "string"
:minLength 1}}
:paths {"/api/spec/plus/{z}" {:patch {:parameters []
:summary "patch"
Expand Down

0 comments on commit 98f3eb0

Please sign in to comment.