且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在游戏框架中运行测试时如何应用游戏进化?

更新时间:2023-12-05 13:16:40

您可以使用以下内容在每个套件之前应用演变,然后进行清理:

You can use the following to apply evolutions before each suite and clean up afterwards:

trait DatabaseSupport extends BeforeAndAfterAll {
  this: Suite with ServerProvider =>

  private lazy val db = app.injector.instanceOf[DBApi]

  override protected def beforeAll(): Unit = {
    super.beforeAll()
    initializeEvolutions(db.database("default"))
  }

  override protected def afterAll(): Unit = {
    cleanupEvolutions(db.database("default"))
    super.afterAll()
  }

  private def initializeEvolutions(database: Database):Unit = {
    Evolutions.cleanupEvolutions(database)
    Evolutions.applyEvolutions(database)
  }

  private def cleanupEvolutions(database: Database):Unit = {
    Evolutions.cleanupEvolutions(database)
  }

}