From d641660545d5e278c37c487c770414ec7edf722c Mon Sep 17 00:00:00 2001 From: Evgenii Afanasev Date: Tue, 5 Nov 2024 21:24:32 +0300 Subject: [PATCH] fix spec --- .gitignore | 4 ++++ magnum/src/main/scala/com/augustnagro/magnum/Spec.scala | 2 +- magnum/src/test/scala/PgTests.scala | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 57e5a62..2fa9e4b 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,7 @@ hs_err_pid* *.sc *.db + +*metals* +.bloop +.vscode \ No newline at end of file diff --git a/magnum/src/main/scala/com/augustnagro/magnum/Spec.scala b/magnum/src/main/scala/com/augustnagro/magnum/Spec.scala index 54e725e..0949877 100644 --- a/magnum/src/main/scala/com/augustnagro/magnum/Spec.scala +++ b/magnum/src/main/scala/com/augustnagro/magnum/Spec.scala @@ -68,7 +68,7 @@ class Spec[E] private ( val fragWriter: FragWriter = (ps, startingPos) => validFrags.foldLeft(startingPos)((pos, frag) => - pos + frag.writer.write(ps, pos) + frag.writer.write(ps, pos) ) Frag(finalSj.toString, allParams.result(), fragWriter) diff --git a/magnum/src/test/scala/PgTests.scala b/magnum/src/test/scala/PgTests.scala index f9c664c..c1a42be 100644 --- a/magnum/src/test/scala/PgTests.scala +++ b/magnum/src/test/scala/PgTests.scala @@ -65,6 +65,15 @@ class PgTests extends FunSuite, TestContainersFixtures: .where(sql"${car.topSpeed} > $topSpeed") assertEquals(carRepo.findAll(spec), Vector(allCars(1))) + test("findAll spec with multiple conditions"): + connect(ds()): + val topSpeed = 211 + val model = "Ferrari F8 Tributo" + val spec = Spec[Car] + .where(sql"${car.topSpeed} > $topSpeed") + .where(sql"${car.model} = $model") + assertEquals(carRepo.findAll(spec), Vector(allCars(1))) + test("findById"): connect(ds()): assertEquals(carRepo.findById(3L).get, allCars.last)