Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zio-test: compile error on assertion on zio.Cause #8539

@domdorn

Description

@domdorn

There seems to be a problem with the assertTrue macro when working with zio.Cause and contains.. I have to cast the element I'm looking for

compile error:

[error] /Users/domdorn/acme/jobs-service/src/test/scala/com/acme/project/jobs/adapters/outbound/persistence/slick/CalcRepositorySpec.scala:372:37: type mismatch;
[error]  found   : zio.test.TestArrow[Seq[zio.Cause[com.acme.project.jobs.business.api.RestartCalc.RestartCalcException.CalculationNotFoundException.type]],Boolean]
[error]  required: zio.test.TestArrow[List[zio.Cause[com.acme.project.jobs.business.api.RestartCalc.RestartCalcException]],?]
[error]                   } yield assertTrue(r.failures.contains(zio.Cause.fail(CalculationNotFoundException)))

test-code not working:

                  for {
                    jobRepo <- ZIO.service[JobRepositoryImpl]
                    repo <- ZIO.service[CalcRepositoryImpl]
                    r <- repo.restartCalculation(c, u, JobId.random(), CalcId.random(), someTs).sandbox.cause
                  } yield assertTrue(r.failures.contains(zio.Cause.fail(CalculationNotFoundException)))

                },

test-code that is working

              test("return a CalculationNotFound failure if job does not exist in"){
                  for {
                    jobRepo <- ZIO.service[JobRepositoryImpl]
                    repo <- ZIO.service[CalcRepositoryImpl]
                    r <- repo.restartCalculation(c, u, JobId.random(), CalcId.random(), someTs).sandbox.cause
                  } yield assertTrue(r.failures.contains(zio.Cause.fail(CalculationNotFoundException: RestartCalcException)))

                },

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions