Add game repo tests and implementation
parent
231553acff
commit
825a583b98
|
@ -0,0 +1,17 @@
|
|||
package lila.system
|
||||
package repo
|
||||
|
||||
import model._
|
||||
|
||||
import com.novus.salat._
|
||||
import com.novus.salat.global._
|
||||
import com.novus.salat.dao._
|
||||
import com.mongodb.casbah.MongoCollection
|
||||
import com.mongodb.casbah.Imports._
|
||||
|
||||
class GameRepo(collection: MongoCollection) extends SalatDAO[Game, String](collection) {
|
||||
|
||||
def game(id: String): Option[Game] = findOneByID(id)
|
||||
|
||||
def anyGame = findOne(DBObject())
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package lila.system
|
||||
|
||||
class GameRepoTest extends SystemTest {
|
||||
|
||||
val env = SystemEnv()
|
||||
val repo = env.gameRepo
|
||||
val anyGame = repo.anyGame.get
|
||||
|
||||
"the game repo" should {
|
||||
"find a game" in {
|
||||
"by ID" in {
|
||||
"non existing" in {
|
||||
repo game "haha" must beNone
|
||||
}
|
||||
"existing" in {
|
||||
repo game anyGame.id must beSome.like {
|
||||
case g ⇒ g.id must_== anyGame.id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue