Add game repo tests and implementation

pull/1/merge
Thibault Duplessis 2012-03-01 00:18:38 +01:00
parent 231553acff
commit 825a583b98
2 changed files with 40 additions and 0 deletions

View File

@ -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())
}

View File

@ -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
}
}
}
}
}
}