You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As an example, I have 2 test containers, Mysql and Kafka.
Some integration tests require only Mysql and some only Kafka, which works with this pattern
trait SharedDatabaseSpec extends ZIOSpec[TestEnvironment with MySQLContainer] {
override val bootstrap: ZLayer[Any, Nothing, TestEnvironment with MySQLContainer] = testEnvironment ++ ZMySQLContainer.live
}
trait SharedKafkaSpec extends ZIOSpec[TestEnvironment with KafkaContainer] {
override val bootstrap: ZLayer[Any, Nothing, TestEnvironment with KafkaContainer] = testEnvironment ++ KafkaContainer.live
}
But with some tests that require both Kafka and Database containers, this pattern no longer works.
MyExampleSpec extends SharedDatabaseSpec with SharedKafkaSpec { ... }
illegal inheritance;
self-type RecoveryIntegrationSpec.type does not conform to zio.test.ZIOSpec[zio.test.TestEnvironment with com.dimafeng.testcontainers.MySQLContainer]'s selftype zio.test.ZIOSpec[zio.test.TestEnvironment with com.dimafeng.testcontainers.MySQLContainer]
object RecoveryIntegrationSpec extends SharedDatabaseSpec with SharedKafkaSpec {
I assume this is because both are overriding bootstrap and there isn't a way to compose at the traits level. One option I considered is to just have another trait which includes both types but I couldn't figure out if there's a way to memoize or re-use the same containers from the previous traits.
trait SharedContainerSpec extends ZIOSpec[TestEnvironment with KafkaContainer with MySQLContainer] {
override val bootstrap: ZLayer[Any, Nothing, TestEnvironment with KafkaContainer] = testEnvironment ++ KafkaContainer.live ++ ZMySQLContainer.live
}
Is there any other way to achieve what I'm looking to do or is that not possible at the moment?
Also somewhat related to the layer sharing, is there a reason provideSome supports providing a list of layers, but provideSomeLayerShared only accepts a single zlayer?
The text was updated successfully, but these errors were encountered:
Going off this example https://zio.dev/reference/test/sharing-layers-between-multiple-files, I'm able to get a single resource shared but this doesn't seem possible if I want to share multiple resources.
As an example, I have 2 test containers, Mysql and Kafka.
Some integration tests require only Mysql and some only Kafka, which works with this pattern
But with some tests that require both Kafka and Database containers, this pattern no longer works.
I assume this is because both are overriding bootstrap and there isn't a way to compose at the traits level. One option I considered is to just have another trait which includes both types but I couldn't figure out if there's a way to memoize or re-use the same containers from the previous traits.
Is there any other way to achieve what I'm looking to do or is that not possible at the moment?
Also somewhat related to the layer sharing, is there a reason
provideSome
supports providing a list of layers, butprovideSomeLayerShared
only accepts a single zlayer?The text was updated successfully, but these errors were encountered: