Skip to content

Commit

Permalink
fix spec (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgenyAfanasev authored Nov 13, 2024
1 parent 8219784 commit d33f6ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ hs_err_pid*

*.sc
*.db

*metals*
.bloop
.vscode
2 changes: 1 addition & 1 deletion magnum/src/main/scala/com/augustnagro/magnum/Spec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions magnum/src/test/scala/PgTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d33f6ec

Please sign in to comment.