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

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ object TestAspectSpec extends ZIOBaseSpec {
for {
_ <- ZIO.sleep(1.nanosecond)
} yield assertCompletes
} @@ withLiveEnvironment
} @@ withLiveEnvironment,
test("withConfigProvider runs tests with the specified config provider") {
for {
value <- ZIO.config(Config.string("key"))
} yield assertTrue(value == "value")
} @@ withConfigProvider(ConfigProvider.fromMap(Map("key" -> "value")))
)

def diesWithSubtypeOf[E](implicit ct: ClassTag[E]): TestFailure[E] => Boolean =
Expand Down
9 changes: 9 additions & 0 deletions test/shared/src/main/scala/zio/test/TestAspect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,15 @@ object TestAspect extends TimeoutVariants {
*/
val windows: TestAspectPoly = os(_.isWindows)

/**
* An aspect that runs tests with the specified config provider.
*/
def withConfigProvider(configProvider: ConfigProvider): TestAspectPoly =
new TestAspectPoly {
def some[R, E](spec: Spec[R, E])(implicit trace: Trace): Spec[R, E] =
spec.provideSomeLayer[R](ZLayer.scoped(ZIO.withConfigProviderScoped(configProvider)))
}

/**
* An aspect that runs tests with the live clock service.
*/
Expand Down