Skip to content

Commit 51464ce

Browse files
committed
Lint-fix, testing doc
1 parent 70b67f6 commit 51464ce

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/codes/clj/docs/backend/config.clj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
(ns codes.clj.docs.backend.config
2-
(:require [aero.core :as aero]
3-
[clojure.string :as string]))
2+
(:require [aero.core :as aero]
3+
[clojure.string :as string]))
44

55
(defn- str-var->vector-var
66
"Converts a string config variable to a vector of strings, when applicable.
77
Environment variables are expected to be set as comma-separated values."
88
[value]
99
(if (string? value)
10-
(let [split-configs (-> value
11-
(string/split #","))
12-
env-config (->> split-configs
13-
(map string/trim)
14-
(remove empty?))]
15-
env-config)
16-
value))
10+
(let [split-configs (-> value
11+
(string/split #","))
12+
env-config (->> split-configs
13+
(map string/trim)
14+
(remove empty?))]
15+
env-config)
16+
value))
1717

18-
(defmethod aero/reader 'csv
18+
(defmethod aero/reader 'csv
1919
[_ _ value]
2020
(str-var->vector-var value))

test/unit/codes/clj/docs/backend/config_test.clj

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
(use-fixtures :once helpers.malli/with-intrumentation)
99

1010
(deftest str-var->vector-var-test
11-
(testing "root-level configs should be converted to vectors"
12-
(is (match? ["value1" "value2"]
13-
(#'backend.config/str-var->vector-var "value1, value2"))))
11+
(testing "csv configs should be converted to vectors"
12+
(is (match? ["value1" "value2"]
13+
(#'backend.config/str-var->vector-var "value1, value2"))))
1414

15-
(testing "trailing and extra whitespaces should be ignored"
16-
(is (match? ["value3" "value4" "value5"]
17-
(#'backend.config/str-var->vector-var "value3, value4,value5, "))))
15+
(testing "trailing and extra whitespaces should be ignored"
16+
(is (match? ["value3" "value4" "value5"]
17+
(#'backend.config/str-var->vector-var "value3, value4,value5, "))))
1818

19-
(testing "trailing commas should be ignored"
20-
(is (match? ["value6" "value7"]
21-
(#'backend.config/str-var->vector-var "value6, value7,")))))
19+
(testing "trailing commas should be ignored"
20+
(is (match? ["value6" "value7"]
21+
(#'backend.config/str-var->vector-var "value6, value7,")))))
2222

2323
(deftest csv-reader-test
24-
(testing "tag literal #csv should turn comma-separated strings into vectors"
25-
(is (match? {:some-config ["value1" "value2"]
26-
:malformed-config ["value3" "value4" "value5"]
27-
:trailing-comma-config ["value6" "value7"]}
28-
(aero/read-config "test/resources/csv-config.edn")))))
24+
(testing "tag literal #csv should turn comma-separated strings into vectors"
25+
(is (match? {:some-config ["value1" "value2"]
26+
:malformed-config ["value3" "value4" "value5"]
27+
:trailing-comma-config ["value6" "value7"]}
28+
(aero/read-config "test/resources/csv-config.edn")))))

0 commit comments

Comments
 (0)