diff --git a/driver/src/test/scala/BSONCollectionSpec.scala b/driver/src/test/scala/BSONCollectionSpec.scala index 6fdb81149..f87b6a2dd 100644 --- a/driver/src/test/scala/BSONCollectionSpec.scala +++ b/driver/src/test/scala/BSONCollectionSpec.scala @@ -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) diff --git a/driver/src/test/scala/GridfsSpec.scala b/driver/src/test/scala/GridfsSpec.scala index 1052638b2..c257ca8f5 100644 --- a/driver/src/test/scala/GridfsSpec.scala +++ b/driver/src/test/scala/GridfsSpec.scala @@ -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].