Skip to content

Commit 160c437

Browse files
committed
Add main_test.clj
1 parent 5080a78 commit 160c437

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/eca/main_test.clj

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(ns eca.main-test
2+
(:require
3+
[clojure.test :refer [are deftest is testing use-fixtures]]
4+
[eca.main :as main]
5+
[matcher-combinators.config]
6+
[matcher-combinators.matchers :as m]
7+
[matcher-combinators.test :refer [match?]]))
8+
9+
(use-fixtures :once #(binding [matcher-combinators.config/*use-abbreviation* true] (%)))
10+
11+
(deftest parse-opts-test
12+
(are [args expected] (match? expected (#'main/parse-opts args))
13+
;; help
14+
[] {:options {:help m/absent}}
15+
["--help"] {:options {:help true}}
16+
["-h"] {:options {:help true}}
17+
;; version
18+
[] {:options {:version m/absent}}
19+
["--version"] {:options {:version true}}
20+
["-v"] {:options {:version m/absent}}
21+
;; verbose
22+
[] {:options {:verbose m/absent}}
23+
["--verbose"] {:options {:verbose true}}
24+
["-v"] {:options {:verbose m/absent}}
25+
#_()))
26+
27+
(deftest parse
28+
(testing "commands"
29+
(is (= nil (:action (#'main/parse []))))
30+
(is (= "server" (:action (#'main/parse ["server"])))))
31+
(testing "final options"
32+
(is (string? (:exit-message (#'main/parse ["--help"]))))
33+
(is (string? (:exit-message (#'main/parse ["-h"]))))
34+
(is (string? (:exit-message (#'main/parse ["--version"]))))))

0 commit comments

Comments
 (0)