Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

MatchError using @mockable for services returning ZSink #54

Open
felix-hedenstrom opened this issue Feb 6, 2024 · 0 comments
Open

MatchError using @mockable for services returning ZSink #54

felix-hedenstrom opened this issue Feb 6, 2024 · 0 comments

Comments

@felix-hedenstrom
Copy link
Contributor

felix-hedenstrom commented Feb 6, 2024

I haven't seen any documentation where you mention that you support this but I noticed that zio-mock supported ZStream as a return type so I was hoping that you would also support ZSink.

I found this behavior when testing using
zio=2.0.15, zio-stream=2.0.15, zio-mock=1.0.0-RC10

The behavior seems to be the same in 1.0.0-RC12.

import zio.mock.{MockSpecDefault, mockable}
import zio.stream.ZSink

trait Bar {
  def zsink: ZSink[Any, Nothing, Any, Nothing, Long]
}

object FooSpec extends MockSpecDefault {
  @mockable[Bar]
  object BarMock
}

when compiling this the compiler returns

exception during macro expansion: 
scala.MatchError: (Sink(Any,Nothing,Any,Nothing,Long),false,false,false) (of class scala.Tuple4)
	at zio.mock.MockableMacro$.zio$mock$MockableMacro$$makeTag$1(MockableMacro.scala:161)
	at zio.mock.MockableMacro$$anonfun$1.applyOrElse(MockableMacro.scala:297)
	at zio.mock.MockableMacro$$anonfun$1.applyOrElse(MockableMacro.scala:295)
	at scala.collection.StrictOptimizedIterableOps.collect(StrictOptimizedIterableOps.scala:151)
	at scala.collection.StrictOptimizedIterableOps.collect$(StrictOptimizedIterableOps.scala:136)
	at scala.collection.immutable.HashMap.collect(HashMap.scala:39)
	at zio.mock.MockableMacro$.impl(MockableMacro.scala:295)

Is this an expected error?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant