在为我的测试提供图层时,我偶然发现了这种奇怪的行为,即无法提取值中的图层。
此代码编译:
def spec: ZSpec[environment.TestEnvironment, Any] =
suite("EnvironmentLoaderSuites")(
testM("the Config is correct") {
assertM(environmentLoader.bpfEnv())(
equalTo(expectedEnv))
}
).provideCustomLayer(Console.live >>> loggings.consoleLogger >>> environmentLoader.live(testEnvPath))
当我现在像这样提取图层时:
val layers = Console.live >>> loggings.consoleLogger >>> environmentLoader.live(testEnvPath)
def spec: ZSpec[environment.TestEnvironment, Any] =
suite("EnvironmentLoaderSuites")(
testM("the Config is correct") {
assertM(environmentLoader.bpfEnv())(
equalTo(expectedEnv))
}
).provideCustomLayer(layers)
我得到以下编译异常:
Error:(48, 26) type mismatch;
found : zio.ZLayer[Any,Throwable,finnova.bpf.client.environmentLoader.EnvironmentLoader]
(which expands to) zio.ZLayer[Any,Throwable,zio.Has[finnova.bpf.client.environmentLoader.Service]]
required: zio.ZLayer[zio.test.environment.TestEnvironment,zio.test.TestFailure[Any],?]
(which expands to) zio.ZLayer[zio.Has[zio.clock.Clock.Service] with zio.Has[zio.console.Console.Service] with zio.Has[zio.system.System.Service] with zio.Has[zio.random.Random.Service] with zio.Has[zio.blocking.Blocking.Service] with zio.Has[zio.test.Annotations.Service] with zio.Has[zio.test.environment.TestClock.Service] with zio.Has[zio.test.environment.TestConsole.Service] with zio.Has[zio.test.environment.Live.Service] with zio.Has[zio.test.environment.TestRandom.Service] with zio.Has[zio.test.Sized.Service] with zio.Has[zio.test.environment.TestSystem.Service],zio.test.TestFailure[Any],?]
).provideCustomLayer(layers)
这是ZIO Test的限制还是我错过了什么?