1

I have the following function I want to mock:

def deployments(): Task[Seq[Deployment]]

My envBuilder looks like:

ZLayer.fromService(invoke =>
        new processEngineService.Service {
          def deployments(): Task[Seq[Deployment]] =
            invoke(Deployments)
        }
      )

How can I set up my expectations for this?

Following the docs (GetStrLn returns value("42")) I tried:

ProcessEngineMock.Deployments returns value(Seq(deployment))

But this gives me:

- unsatisfied expectations
  in sequential order
    ..ProcessEngineMock.Deployments with arguments isUnit()

How is this done correctly?

pme
  • 14,156
  • 3
  • 52
  • 95
  • Why do you need to mock is you are using ZIO? – Mateusz Kubuszok May 04 '20 at 19:26
  • @MateuszKubuszok yes I use ZIO and I want to mock this Service because it would require to startup a BPMN Engine. – pme May 05 '20 at 04:51
  • From the code it looks like your service is Single Abstract Method. Instead of mocking it you can pretty much build ZLayer using something like `val service: processEngineService.Service = () => Task.pure(Seq(deployment))` and provide that ZLayer to your code. – Mateusz Kubuszok May 05 '20 at 08:52
  • @MateuszKubuszok - thanks - I just simplified there are more functions - and I want to give zio test mock a try;). But maybe I have to settle with your proposal. – pme May 05 '20 at 15:32

0 Answers0