Skip to content

Commit bcdb55d

Browse files
committed
codec tests added
1 parent 4d2f881 commit bcdb55d

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

build.sbt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ developers := List(
8686
url = url("https://github.com/sfxcode")
8787
)
8888
)
89+
90+
coverageMinimum := 60
91+
92+
coverageFailOnMinimum := true

src/test/scala/com/sfxcode/nosql/mongo/TestDatabase.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ object TestDatabase extends ObservableImplicits {
1717

1818
private val personRegistry = fromProviders(classOf[Person], classOf[Friend])
1919

20-
private val lineRegistry = fromProviders(classOf[Line], classOf[Position])
20+
private val lineRegistry = fromProviders(classOf[Line], classOf[Position])
21+
private val codecTestRegistry = fromProviders(classOf[CodecTest])
2122

22-
val provider = DatabaseProvider("simple_mongo_test", fromRegistries(bookRegistry, personRegistry, lineRegistry))
23+
val provider =
24+
DatabaseProvider("simple_mongo_test", fromRegistries(bookRegistry, personRegistry, lineRegistry, codecTestRegistry))
2325

2426
object BookDAO extends MongoDAO[Book](provider, "books")
2527

2628
object LineDAO extends MongoDAO[Line](provider, "lines") with CrudObserver[Line]
2729

2830
object PersonDAO extends MongoDAO[Person](provider, "person")
2931

32+
object CodecDao extends MongoDAO[CodecTest](provider, "codec-test")
33+
3034
val dropResult: Void = PersonDAO.drop()
3135

3236
val persons: List[Person] = Person.personList
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.sfxcode.nosql.mongo.model
2+
3+
case class CodecTest(id: Long = 1,
4+
bd: BigDecimal = BigDecimal(BigDecimal.getClass.getSimpleName.length.toDouble),
5+
bi: BigInt = BigInt(BigInt.getClass.getSimpleName.length))

src/test/scala/com/sfxcode/nosql/mongo/operation/CrudSpec.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.sfxcode.nosql.mongo.operation
22

33
import com.sfxcode.nosql.mongo.TestDatabase._
44
import com.sfxcode.nosql.mongo._
5-
import com.sfxcode.nosql.mongo.model.Line
5+
import com.sfxcode.nosql.mongo.model.{ CodecTest, Line }
66
import org.specs2.mutable.Specification
77

88
class CrudSpec extends Specification {
@@ -45,6 +45,14 @@ class CrudSpec extends Specification {
4545

4646
}
4747

48+
"create Documents in" in {
49+
CodecDao.drop().headResult()
50+
CodecDao.insertOne(CodecTest()).headResult()
51+
CodecDao.count().headResult() must be equalTo 1
52+
val findOneResult = CodecDao.find("id", 1).result()
53+
findOneResult must beSome[CodecTest]
54+
}
55+
4856
}
4957

5058
}

0 commit comments

Comments
 (0)