-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Dependencies a first-class concept
- Loading branch information
Showing
5 changed files
with
33 additions
and
45 deletions.
There are no files selected for viewing
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
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
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
17 changes: 5 additions & 12 deletions
17
...mill/bootzooka/test/AppDependencies.scala → ...ill/bootzooka/test/TestDependencies.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 |
---|---|---|
@@ -1,32 +1,25 @@ | ||
package com.softwaremill.bootzooka.test | ||
|
||
import cats.effect.{IO, Resource} | ||
import com.softwaremill.bootzooka.DependenciesFactory | ||
import com.softwaremill.bootzooka.email.EmailService | ||
import com.softwaremill.bootzooka.http.HttpApi | ||
import com.softwaremill.bootzooka.Dependencies | ||
import org.scalatest.{BeforeAndAfterAll, Suite} | ||
import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend | ||
|
||
trait AppDependencies extends BeforeAndAfterAll with TestEmbeddedPostgres { self: Suite with BaseTest => | ||
|
||
var httpApi: HttpApi = _ | ||
var emailService: EmailService = _ | ||
trait TestDependencies extends BeforeAndAfterAll with TestEmbeddedPostgres { self: Suite with BaseTest => | ||
var dependencies: Dependencies = _ | ||
|
||
override protected def beforeAll(): Unit = { | ||
super.beforeAll() | ||
|
||
val deps = { | ||
dependencies = { | ||
import cats.effect.unsafe.implicits.global | ||
|
||
DependenciesFactory.resource( | ||
Dependencies.wire( | ||
config = TestConfig, | ||
sttpBackend = Resource.pure(AsyncHttpClientFs2Backend.stub[IO]), | ||
xa = Resource.pure(currentDb.xa), | ||
clock = testClock | ||
).allocated.unsafeRunSync()._1 | ||
} | ||
|
||
httpApi = deps._1 | ||
emailService = deps._2 | ||
} | ||
} |
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