Skip to content

Commit

Permalink
fix: filter missing mocks correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
J0sueTM committed May 27, 2024
1 parent c90dace commit ab5fff7
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/yaml_generator/logic/yml.clj
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,25 @@
(every? (fn [{:keys [endpoint]}]
(some #(and (= (:path endpoint)
(get-in % [:endpoint :path]))
(= (:method endpoint)
(get-in % [:endpoint :method]))
(= (get endpoint host-key)
(get-in % [:endpoint host-key])))
unified))
(:content mock))
#_(let [endpoint (get-in mock [:content :endpoint])]
(some #(and (= (:path endpoint) (get-in % [:endpoint :path]))
(= (get endpoint host-key) (get-in % [:endpoint host-key])))
unified)))
(:content unified)))
(:content mock)))
mocks))

(comment
(filter-missing-mocks
[{:path "cd989358-af38-4a2f-a1a1-88096aa425a7/10f62424-c8f7-4793-bc7c-bfe5d26655a5/mock.yml"
:content [{:endpoint
{:method "GET"
:path "/hello/:username"
:local-host "test-j0suetm.moclojer.com"}}]}]
{:path "moclojer.yml", :content []}
:host)
;; => ({:path "cd989358-af38-4a2f-a1a1-88096aa425a7/10f62424-c8f7-4793-bc7c-bfe5d26655a5/mock.yml", :content [{:endpoint {:method "GET", :path "/hello/:username", :local-host "test-j0suetm.moclojer.com"}}]})

(filter-missing-mocks
[{:path "cd989358-af38-4a2f-a1a1-88096aa425a7/10f62424-c8f7-4793-bc7c-bfe5d26655a5/mock.yml"
:content [{:endpoint
Expand All @@ -105,8 +113,14 @@
:headers {:Content-Type "application/json"}
:body "{\n \"hello\": \"{{path-params.username}}!\"\n}"}
:local-host "test-j0suetm.moclojer.com"}}]}]
{:path "moclojer.yml", :content []}
{:path "moclojer.yml"
:content [{:endpoint
{:method "GET"
:path "/hello/:username"
:response {:status 200
:headers {:Content-Type "application/json"}
:body "{\n \"hello\": \"{{path-params.username}}!\"\n}"}
:local-host "test-j0suetm.moclojer.com"}}]}
:host)

;;
;; => ()
)

0 comments on commit ab5fff7

Please sign in to comment.