Skip to content

Commit

Permalink
More functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vganshin committed Sep 13, 2019
1 parent c0ba799 commit b23e346
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ Example:
### Custom Predicates
- `ok?` -- `(and (>= % 200) (< % 300))`
- `4xx?`
- `5xx?`

## Regex

Expand Down
2 changes: 2 additions & 0 deletions src/matcho.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

(def fns
{"ok?" #(and (> % 199) (< % 300))
"4xx?" #(and (> % 400) (< % 500))
"5xx?" #(and (> % 500) (< % 600))
}
)

Expand Down
14 changes: 10 additions & 4 deletions src/runner.clj
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,19 @@
(defn verbose-enough? [ctx expected-lvl]
(>= (or (:verbosity ctx) 0) expected-lvl))

(comment



)

(defn exec-step [{:keys [conf steps] :as ctx} step]
(cond
;; skip next steps if some previous one in the test-case was failed
(or (:failed? ctx) (:skip step))
(or (= (:status ctx) "failed") (:skip step))
(do
(println (colors/yellow "skip step") (:id step))
(assoc step :skipped? true))
(assoc step :status "skipped" :skipped? true))

:else
(do
Expand Down Expand Up @@ -111,14 +117,14 @@
(pprint/pretty {:ident 0 :path [] :errors errs} resp)
(assoc step
:failed? true
:status "failed"
:errors errs
:resp resp))))
(assoc step :failed? true :message "Cannot create requrest")))))

(defn get-id [test-case]
(or (:id test-case) (:filename test-case)))


(defn run-step [{:keys [conf steps] :as ctx} step]
(let [result (exec-step ctx step)]
(-> ctx
Expand Down Expand Up @@ -160,7 +166,7 @@
(let [test-case (read-test-case filename)]
(when (valid? ctx test-case)
(let [result (run-test-case conf test-case)]
(update-in ctx [:test-cases] #(conj % result))))))
(update ctx :test-cases #(conj % result))))))

(defn get-summary [{test-cases :test-cases}]
(let [failed-tests (filter :failed? test-cases)
Expand Down

0 comments on commit b23e346

Please sign in to comment.