From de5cf77cbb297ba30045252a43cb2ab29cc666ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Renoux?= Date: Sun, 24 Mar 2024 16:52:39 +0100 Subject: [PATCH] Adds compile-time tests --- .../tranzactio/DatabaseOpsCompileTest.scala | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/src/test/scala/io/github/gaelrenoux/tranzactio/DatabaseOpsCompileTest.scala b/core/src/test/scala/io/github/gaelrenoux/tranzactio/DatabaseOpsCompileTest.scala index 632ef30..6216512 100644 --- a/core/src/test/scala/io/github/gaelrenoux/tranzactio/DatabaseOpsCompileTest.scala +++ b/core/src/test/scala/io/github/gaelrenoux/tranzactio/DatabaseOpsCompileTest.scala @@ -229,6 +229,26 @@ trait DatabaseOpsCompileTest { } + + val typedServiceOperations: DatabaseTBase[Marker, Connection] + val typedModuleOperations: DatabaseTBase.Module[Marker, Connection, DatabaseService] + + object DatabaseTChecks { + + val a: ZIO[Environment, Either[DbException, String], Int] = + typedServiceOperations.transaction(z[Connection with Environment, String]) + + val b: ZIO[Any, Either[DbException, String], Int] = + typedServiceOperations.transaction(z[Connection, String]) + + val c: ZIO[DatabaseT[Marker] with Environment, Either[DbException, String], Int] = + typedModuleOperations.transaction(z[Connection with Environment, String]) + + val d: ZIO[DatabaseT[Marker], Either[DbException, String], Int] = + typedModuleOperations.transaction(z[Connection, String]) + + } + } object DatabaseOpsCompileTest { @@ -239,5 +259,9 @@ object DatabaseOpsCompileTest { type Database = DatabaseService + type DatabaseT[M] = DatabaseTBase[M, Connection] + trait Environment + + trait Marker }