Skip to content

Commit

Permalink
Add sort to the test coverage (#631)
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed Feb 18, 2017
1 parent 83df751 commit 0bba42b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 5 additions & 2 deletions driver/src/test/scala/BSONCollectionSpec.scala
Expand Up @@ -132,8 +132,11 @@ class BSONCollectionSpec extends org.specs2.mutable.Specification {

"read until John" in { implicit ee: EE =>
implicit val reader = PersonReader
@inline def cursor = findAll(collection).cursor[Person]()
val persons = Seq(person, person2, person3)
@inline def cursor = findAll(collection).sort(
BSONDocument("age" -> 1)
).cursor[Person]()

val persons = Seq(person2, person4, person, person3)

cursor.foldWhile(Nil: Seq[Person])({ (s, p) =>
if (p.name == "John") Cursor.Done(s :+ p)
Expand Down
13 changes: 11 additions & 2 deletions driver/src/test/scala/GridfsSpec.scala
Expand Up @@ -53,14 +53,23 @@ class GridFSSpec extends org.specs2.mutable.Specification {
def find(n: String): Future[Option[GFile]] =
gfs.find(BSONDocument("filename" -> n)).headOption

def matchFile(actual: GFile, expected: DefaultFileToSave, content: Array[Byte]) = actual.filename must_== expected.filename and (
def matchFile(
actual: GFile,
expected: DefaultFileToSave,
content: Array[Byte]
) = actual.filename must_== expected.filename and (
actual.uploadDate must beSome
) and (actual.contentType must_== expected.contentType) and {
import scala.collection.mutable.ArrayBuilder
def res = gfs.enumerate(actual) |>>>
Iteratee.fold(ArrayBuilder.make[Byte]()) { _ ++= _ }

res.map(_.result()) must beEqualTo(content).await(1, timeout)
val buf = new java.io.ByteArrayOutputStream()

res.map(_.result()) must beEqualTo(content).await(1, timeout) and {
gfs.readToOutputStream(actual, buf).
map(_ => buf.toByteArray) must beEqualTo(content).await(1, timeout)
}
}

find(filename1) aka "file #1" must beSome[GFile].
Expand Down

0 comments on commit 0bba42b

Please sign in to comment.