aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJakob Odersky <jakob@driver.xyz>2018-09-12 17:30:33 -0700
committerJakob Odersky <jakob@odersky.com>2018-10-09 16:19:39 -0700
commiteb6f97b4cac548999cbf192ee83d9ba9a253b7c8 (patch)
tree6d75a23efc841a6f51e780913387000206d1fe94 /src/test
parent4d1197099ce4e721c18bf4cacbb2e1980e4210b5 (diff)
downloaddriver-core-eb6f97b4cac548999cbf192ee83d9ba9a253b7c8.tar.gz
driver-core-eb6f97b4cac548999cbf192ee83d9ba9a253b7c8.tar.bz2
driver-core-eb6f97b4cac548999cbf192ee83d9ba9a253b7c8.zip
Move database-related functionality to separate project
This committ includes a breaking change. The database-specific utility "Converters" trait threw an exception "DatabaseException" defined in the rest package, thus breaking the dependency graph. The solution was to move the DatabaseException class from rest to database and not inherit ServiceExceptio any more. Unfortunately, the rest classes also require the database exception in propagating errors so this funtionality has been removed. The rationale is: 1. Database exceptions are rare and result in 500 errors anyway making the status code opaque to what actual error caused it. 2. In core 2.0, an improved tracing framework will make diagnosing and following database errors easier, thereby attenuating the need to forward details on service exceptions in responses.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/xyz/driver/core/database/DatabaseTest.scala42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/test/scala/xyz/driver/core/database/DatabaseTest.scala b/src/test/scala/xyz/driver/core/database/DatabaseTest.scala
deleted file mode 100644
index 8d2a4ac..0000000
--- a/src/test/scala/xyz/driver/core/database/DatabaseTest.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-package xyz.driver.core.database
-
-import org.scalatest.{FlatSpec, Matchers}
-import org.scalatest.prop.Checkers
-import xyz.driver.core.rest.errors.DatabaseException
-
-class DatabaseTest extends FlatSpec with Matchers with Checkers {
- import xyz.driver.core.generators._
- "Date SQL converter" should "correctly convert back and forth to SQL dates" in {
- for (date <- 1 to 100 map (_ => nextDate())) {
- sqlDateToDate(dateToSqlDate(date)) should be(date)
- }
- }
-
- "Converter helper methods" should "work correctly" in {
- object TestConverter extends Converters
-
- val validLength = nextInt(10)
- val valid = nextToken(validLength)
- val validOp = Some(valid)
- val invalid = nextToken(validLength + nextInt(10, 1))
- val invalidOp = Some(invalid)
- def mapper(s: String): Option[String] = if (s.length == validLength) Some(s) else None
-
- TestConverter.fromStringOrThrow(valid, mapper, valid) should be(valid)
-
- TestConverter.expectValid(mapper, valid) should be(valid)
-
- TestConverter.expectExistsAndValid(mapper, validOp) should be(valid)
-
- TestConverter.expectValidOrEmpty(mapper, validOp) should be(Some(valid))
- TestConverter.expectValidOrEmpty(mapper, None) should be(None)
-
- an[DatabaseException] should be thrownBy TestConverter.fromStringOrThrow(invalid, mapper, invalid)
-
- an[DatabaseException] should be thrownBy TestConverter.expectValid(mapper, invalid)
-
- an[DatabaseException] should be thrownBy TestConverter.expectExistsAndValid(mapper, invalidOp)
-
- an[DatabaseException] should be thrownBy TestConverter.expectValidOrEmpty(mapper, invalidOp)
- }
-}