journal/2021-03-14--13-00-04Z--the_service_pattern.org
This commit is contained in:
parent
d2aa86f0b5
commit
ce1bbd1045
1 changed files with 21 additions and 16 deletions
|
@ -2,7 +2,7 @@
|
|||
#+Author: Yann Esposito
|
||||
#+Date: [2021-03-14]
|
||||
|
||||
- tags :: [[file:2020-06-03--19-49-30Z--programming.org][programming]] [[file:2020-05-26--06-13-41Z--functional_programming.org][functional programming]] [[file:2020-05-26--06-16-14Z--clojure.org][clojure]] [[file:2020-05-26--06-19-53Z--haskell.org][haskell]]
|
||||
- tags :: [[file:2020-06-03--19-49-30Z--programming.org][programming]] [[file:2020-05-26--06-13-41Z--functional_programming.org][functional programming]] [[file:2020-05-26--06-16-14Z--clojure.org][clojure]] [[file:2020-05-26--06-19-53Z--haskell.org][haskell]] [[file:2021-03-20--17-27-46Z--architecture.org][architecture]]
|
||||
- source ::
|
||||
- related :: [[file:2020-12-23--16-50-17Z--effects_system_in_clojure.org][Effects system in Clojure]]
|
||||
|
||||
|
@ -166,10 +166,10 @@ get from this design.
|
|||
functions during your tests.
|
||||
|
||||
#+begin_src clojure
|
||||
(defprotocol UserService
|
||||
(defprotocol UserService
|
||||
(get-user [user-id] "returns a user entity from its id"))
|
||||
|
||||
(defservice user-service
|
||||
(defservice user-service
|
||||
[[:ConfigService get-in-config]
|
||||
[:StoreService read-entity]]
|
||||
(init [this context]
|
||||
|
@ -180,7 +180,12 @@ get from this design.
|
|||
(get-user [this user-id]
|
||||
((:raw-db-get-user (get-context this)) user-id)))
|
||||
|
||||
(defservice stub-user-service
|
||||
(defservice stub-user-service
|
||||
(init [_ context] context)
|
||||
(get-user [user-id] {:id "fake-user-id" ,,,}))
|
||||
|
||||
(def test
|
||||
(start-app [config-service store-service stub-user-service
|
||||
my-service]
|
||||
(test-my-service)))
|
||||
#+end_src
|
||||
|
|
Loading…
Reference in a new issue