Skip to content

Commit

Permalink
Fix it test
Browse files Browse the repository at this point in the history
  • Loading branch information
denis_savitsky committed Feb 4, 2024
1 parent e01dabe commit e732e76
Showing 1 changed file with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OolongMongoUpdateSpec extends AsyncFlatSpec with ForAllTestContainer with
TestClass("1", 1, InnerClass("qwe", 3), Nil, Some(2L), List.empty),
TestClass("2", 2, InnerClass("asd", 0), Nil, None, List.empty),
TestClass("3", 12, InnerClass("sdf", 1), Nil, None, List.empty),
TestClass("12345", 12, InnerClass("sdf", 11), Nil, None, List.empty),
TestClass("12345", 12, InnerClass("sdf", 11), List(1), None, List.empty),
)

implicit val ec = ExecutionContext.global
Expand Down Expand Up @@ -132,39 +132,34 @@ class OolongMongoUpdateSpec extends AsyncFlatSpec with ForAllTestContainer with

it should "update with $addToSet" in {
for {
res <- collection
.updateOne(
upd <- collection
.findOneAndUpdate(
query[TestClass](_.field1 == "0"),
update[TestClass](
_.addToSet(_.field4, 3)
)
)
.head()
upd <- collection
.find(query[TestClass](_.field1 == "0"))
.head()
.map(BsonDecoder[TestClass].fromBson(_).get)

} yield assert(
res.wasAcknowledged() && res.getModifiedCount == 1 && upd.field4.size == 3
upd.field4 == List(1, 2, 3)
)
}

it should "update with $addToSet using $each" in {
for {
res <- collection
.updateOne(
query[TestClass](_.field1 == "0"),
upd <- collection
.findOneAndUpdate(
query[TestClass](_.field1 == "12345"),
update[TestClass](
_.addToSetAll(_.field4, List(4, 5))
_.addToSetAll(_.field4, List(2, 3))
)
)
.head()
upd <- collection
.find(query[TestClass](_.field1 == "0"))
.head()
.map(BsonDecoder[TestClass].fromBson(_).get)
} yield assert(
res.wasAcknowledged() && res.getModifiedCount == 1 && upd.field4.size == 4
upd.field4 == List(1, 2, 3)
)
}

Expand Down

0 comments on commit e732e76

Please sign in to comment.