Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic implementation of action monad and asynchronous execution engine:
- Query, insert, update, delete and schema actions implemented in JdbcProfile. - Query, insert and schema actions implemented in MemoryProfile. - Query actions implemented in DistributedDriver. This is not an optimized implementation based on non-blocking primitives. We simply wrap the existing blocking calls and run them inside of Future(blocking(...)) in the global ExecutionContext. (DistributedDriver in general is not optimized, and is considered experimental at this point.) - As an alternative to TestkitTest, the new AsyncTest class supports test methods that return Futures or Actions, and provides the necessary infrastructure for such tests. Testkit enforces that test methods in TestkitTest subclasses return Unit and that test methods in AsyncTest subclasses return Action or Future. - Further simplifications for Testkit tests: - A string interpolator for generating unique names - A custom matcher instead of Assert.assertEquals - Rename `.ddl` extension method for `TableQuery` to `.schema` - The new API moves some operations to different profile levels: RelationalProfile is required for schema-related features and inserts, JdbcProfile is required for transactions, updates and deletes. BasicProfile only supports querying. - DistributedProfile only extends BasicProfile, not RelationalProfile. The extra operations of RelationalProfile have never been supported anyway. - Upgrade to Xerial-SQLite 3.8.7 to get in-memory databases with shared cache across multiple threads. This is needed for some new test cases. Disabling the test for multi-column primary keys on SQLite for now in ModelBuilderTest. This feature is broken in 3.8.7. Still missing in this version: - Pinned sessions - Wrapping actions for transactions and error handling - Streaming results - Get statements from all insert actions
- Loading branch information
Showing
32 changed files
with
977 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/ActionTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,44 @@ | |||
package com.typesafe.slick.testkit.tests | |||
|
|||
import com.typesafe.slick.testkit.util.{RelationalTestDB, AsyncTest} | |||
|
|||
import scala.concurrent.Future | |||
|
|||
class ActionTest extends AsyncTest[RelationalTestDB] { | |||
import tdb.profile.api._ | |||
|
|||
def testSimpleActionAsFuture = { | |||
class T(tag: Tag) extends Table[Int](tag, u"t") { | |||
def a = column[Int]("a") | |||
def * = a | |||
} | |||
val ts = TableQuery[T] | |||
|
|||
for { | |||
_ <- db.run { | |||
ts.ddl.create >> | |||
(ts ++= Seq(2, 3, 1, 5, 4)) | |||
} | |||
q1 = ts.sortBy(_.a).map(_.a) | |||
f1 = db.run(q1.result) | |||
r1 <- f1 : Future[Seq[Int]] | |||
_ = r1 shouldBe List(1, 2, 3, 4, 5) | |||
} yield () | |||
} | |||
|
|||
def testSimpleActionAsAction = { | |||
class T(tag: Tag) extends Table[Int](tag, u"t") { | |||
def a = column[Int]("a") | |||
def * = a | |||
} | |||
val ts = TableQuery[T] | |||
|
|||
for { | |||
_ <- ts.schema.create | |||
_ <- ts ++= Seq(2, 3, 1, 5, 4) | |||
q1 = ts.sortBy(_.a).map(_.a) | |||
r1 <- q1.result | |||
_ = (r1 : Seq[Int]) shouldBe List(1, 2, 3, 4, 5) | |||
} yield () | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.