Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
frenchy64 committed Apr 24, 2024
1 parent a9c79bd commit 50d48ef
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions test/compojure/api/meta_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
:return (do (swap! times inc) String)
(ok "kikka"))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -357,7 +358,6 @@
:return (do (swap! times inc) String)
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
(is (= 1 @times))))
Expand All @@ -370,6 +370,7 @@
:return (do (swap! times inc) String)
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -385,6 +386,7 @@
:return (do (swap! times inc) s)
(ok "kikka"))))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -399,6 +401,7 @@
(second [req String]))
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -414,6 +417,7 @@
String)
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= {:outer 1 :inner 1} @times))
(exercise)
(is (= {:outer 1 :inner 1} @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -430,6 +434,7 @@
String)
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= {:outer 1 :inner 0} @times))
(exercise)
(is (= {:outer 1 :inner 1} @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -445,6 +450,7 @@
:dynamic true
rs))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand Down Expand Up @@ -485,6 +491,7 @@
:body [body (do (swap! times inc) s/Any)]
(ok "kikka"))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -497,6 +504,7 @@
:body [body (do (swap! times inc) s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -510,6 +518,7 @@
:body [body (do (swap! times inc) s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -525,6 +534,7 @@
:body [body (do (swap! times inc) s)]
(ok "kikka"))))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -539,6 +549,7 @@
(second [req s/Any]))]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand Down Expand Up @@ -568,6 +579,7 @@
s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= {:outer 1 :inner 0} @times))
(exercise)
(is (= {:outer 1 :inner 1} @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -583,6 +595,7 @@
:dynamic true
rs))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand Down Expand Up @@ -623,6 +636,7 @@
:query [body (do (swap! times inc) s/Any)]
(ok "kikka"))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -635,6 +649,7 @@
:query [body (do (swap! times inc) s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -648,6 +663,7 @@
:query [body (do (swap! times inc) s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -663,6 +679,7 @@
:query [body (do (swap! times inc) s)]
(ok "kikka"))))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -677,6 +694,7 @@
(second [req s/Any]))]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand Down Expand Up @@ -706,6 +724,7 @@
s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= {:outer 1 :inner 0} @times))
(exercise)
(is (= {:outer 1 :inner 1} @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -721,6 +740,7 @@
:dynamic true
rs))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand Down Expand Up @@ -759,6 +779,7 @@
:responses {200 (do (swap! times inc) String)}
(ok "kikka"))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -771,6 +792,7 @@
:responses {200 (do (swap! times inc) String)}
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -784,6 +806,7 @@
:responses {200 (do (swap! times inc) String)}
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -799,6 +822,7 @@
:responses {200 (do (swap! times inc) s)}
(ok "kikka"))))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -813,6 +837,7 @@
(second [req String]))}
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -828,6 +853,7 @@
String)}
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= {:outer 1 :inner 1} @times))
(exercise)
(is (= {:outer 1 :inner 1} @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -844,6 +870,7 @@
String)}
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= {:outer 1 :inner 0} @times))
(exercise)
(is (= {:outer 1 :inner 1} @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -859,6 +886,7 @@
:dynamic true
rs))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand Down Expand Up @@ -899,6 +927,7 @@
:headers [body (do (swap! times inc) s/Any)]
(ok "kikka"))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -911,6 +940,7 @@
:headers [body (do (swap! times inc) s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -924,6 +954,7 @@
:headers [body (do (swap! times inc) s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -939,6 +970,7 @@
:headers [body (do (swap! times inc) s)]
(ok "kikka"))))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -953,6 +985,7 @@
(second [req s/Any]))]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 0 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand Down Expand Up @@ -982,6 +1015,7 @@
s/Any)]
(ok "kikka")))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= {:outer 1 :inner 0} @times))
(exercise)
(is (= {:outer 1 :inner 1} @times))
(dorun (repeatedly 10 exercise))
Expand All @@ -997,6 +1031,7 @@
:dynamic true
rs))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
(is (= 1 @times))
(exercise)
(is (= 1 @times))
(dorun (repeatedly 10 exercise))
Expand Down Expand Up @@ -1074,15 +1109,20 @@
+compojure-api-request+)]
(do (ok "kikka"))))))}))))
(testing "no context"
(let [times (atom 0)
(let [times (atom {})
record (fn [path schema] (swap! times update path (fnil inc 0)) schema)
route (GET "/ping" []
:body [body (do (swap! times inc) s/Any)]
:body-params [field :- (record :field s/Str)
field2 {default :- (record :default s/Int) (record :default-never (inc 42))}
& foo :- {(record :extra-keys s/Keyword)
(record :extra-vals s/Keyword)} :as all]
(ok "kikka"))
exercise #(is (= "kikka" (:body (route {:request-method :get :uri "/ping"}))))]
exercise #(is (= "kikka" (:body (route {:body-params {:field "a" :field2 2} :request-method :get :uri "/ping"}))))]
(is (= {:field 1 :default 1 :extra-keys 1 :extra-vals 1} @times))
(exercise)
(is (= 1 @times))
(is (= {:field 1 :default 1 :extra-keys 1 :extra-vals 1 :default-never 1} @times))
(dorun (repeatedly 10 exercise))
(is (= 1 @times))))
(is (= {:field 1 :default 1 :extra-keys 1 :extra-vals 1 :default-never 11} @times))))
(testing "inferred static context"
(let [times (atom 0)
route (context
Expand Down

0 comments on commit 50d48ef

Please sign in to comment.