File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 (print (to-csv-line contact )))
1919 plan )
2020
21+ (defn- format-command-errors [command errors ]
22+ (map (fn [error ] (string command " " (string/ascii-lower error ) " ." )) errors ))
23+
2124# # —————————————————————————————————————————————————————————————————————————————————————————————————
2225# # Public Interface
2326
3235 (def argument (arguments " list-contacts" ))
3336 (if argument
3437 (let [load-result (contacts_repository/load-contacts argument )
35- error (load-result :error )]
36- (if error
37- {:errors [( string " --list-contacts " ( string/ascii-lower error ))] }
38+ errors (load-result :errors )]
39+ (if errors
40+ {:errors ( format-command-errors " --list-contacts" errors ) }
3841 {:command [print-contacts (load-result :contacts )]}))
3942 {}))
Original file line number Diff line number Diff line change 5151(defn- schedule-birthday-tasks [plan contacts today ]
5252 (schedule-tasks plan contacts today birthday-prefix contact/birthday? ))
5353
54+ (defn- format-command-errors [command errors ]
55+ (map (fn [error ] (string command " " (string/ascii-lower error ) " ." )) errors ))
56+
5457# # —————————————————————————————————————————————————————————————————————————————————————————————————
5558# # Public Interface
5659
6467 (def argument (arguments " schedule-contacts" ))
6568 (if argument
6669 (let [load-result (contacts_repository/load-contacts argument )
67- error (load-result :error )
70+ errors (load-result :errors )
6871 contacts (load-result :contacts )]
69- (if error
70- {:errors [( string " --schedule-contacts " ( string/ascii-lower error ))] }
72+ (if errors
73+ {:errors ( format-command-errors " --schedule-contacts" errors ) }
7174 {:command [schedule-contacts contacts (date/today )]}))
7275 {}))
Original file line number Diff line number Diff line change 2222 (fn [contact-file ] (load-contact (string directory " /" contact-file )))
2323 (os/dir directory )))]
2424 {:contacts contacts })
25- {:error " Directory does not exist. " }))
25+ {:errors [ " Directory does not exist" ] }))
Original file line number Diff line number Diff line change 1414
1515(deftest load-contacts-when-directory-does-not-exist
1616 (def result (load-contacts " test/missing-directory" ))
17- (is (= " Directory does not exist. " (result :error ))))
17+ (is (= " Directory does not exist" (first ( result :errors ) ))))
1818
1919(run-tests! )
You can’t perform that action at this time.
0 commit comments