-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better handling mocks for methods taking implicit Tag types
- Loading branch information
1 parent
94c7453
commit c1f09df
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
input/src/main/scala/rewrite/mockable/ImplicitsParams.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
rule = ZIOMockableCodeGen | ||
*/ | ||
package rewrite.mockable | ||
|
||
import zio._ | ||
import zio.stream.ZSink | ||
import zio.mock._ | ||
import rewrite.accessible._ | ||
|
||
@mockable[ImplicitsParamsService] | ||
object ImplicitsParamsServiceMock | ||
|
||
object ImplicitsParamsServiceMockTest { | ||
implicitly[ImplicitsParamsServiceMock.type <:< Mock[ImplicitsParamsService]] | ||
implicitly[ImplicitsParamsServiceMock.ReduceTransactions.type <:< ImplicitsParamsServiceMock.Poly.Effect.InputErrorOutput] | ||
implicitly[ | ||
ImplicitsParamsServiceMock.EventsForGroup.type <:< ImplicitsParamsServiceMock.Method[GroupId, Throwable, List[TransactionEvent]] | ||
] | ||
} |
33 changes: 33 additions & 0 deletions
33
output/src/main/scala/rewrite/mockable/ImplicitsParams.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package rewrite.mockable | ||
|
||
import zio._ | ||
import zio.stream.ZSink | ||
import zio.mock._ | ||
import rewrite.accessible._ | ||
import zio.mock.Mock | ||
|
||
|
||
object ImplicitsParamsServiceMock extends Mock[ImplicitsParamsService] { | ||
// format: off | ||
// Generated by ZIO Mockable CodeGen Scalafix Rule | ||
case object ReduceTransactions extends Poly.Effect.InputErrorOutput | ||
case object EventsForGroup extends Method[GroupId, Throwable, List[TransactionEvent]] | ||
override val compose: URLayer[Proxy, ImplicitsParamsService] = ZLayer.fromZIO[Proxy, Nothing, ImplicitsParamsService]( | ||
ZIO.service[Proxy].flatMap { proxy => | ||
withRuntime[Proxy, ImplicitsParamsService] { rt => | ||
class MockImpl extends ImplicitsParamsService { | ||
final override def reduceTransactions[R, E, A](groupId: GroupId, sink: ZSink[R, E, TransactionEvent, Nothing, A])(using Tag[R], Tag[E], Tag[A]): ZIO[R, E, A] = proxy(ReduceTransactions.of[(GroupId, ZSink[R, E, TransactionEvent, Nothing, A]), E, A], groupId, sink) | ||
final override def eventsForGroup(id: GroupId)(using Tag[GroupId]): List[TransactionEvent] = Unsafe.unsafe { case given Unsafe => rt.unsafe.run(proxy(EventsForGroup, id)).getOrThrow() } | ||
} | ||
ZIO.succeed(new MockImpl()) | ||
}}) | ||
// format: on | ||
} | ||
|
||
object ImplicitsParamsServiceMockTest { | ||
implicitly[ImplicitsParamsServiceMock.type <:< Mock[ImplicitsParamsService]] | ||
implicitly[ImplicitsParamsServiceMock.ReduceTransactions.type <:< ImplicitsParamsServiceMock.Poly.Effect.InputErrorOutput] | ||
implicitly[ | ||
ImplicitsParamsServiceMock.EventsForGroup.type <:< ImplicitsParamsServiceMock.Method[GroupId, Throwable, List[TransactionEvent]] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters