-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
… only if they ends with brace `(`
- Loading branch information
Showing
3 changed files
with
60 additions
and
3 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
57 changes: 57 additions & 0 deletions
57
src/test/scala/com/github/caiiiycuk/pg2sqlite/dsl/DumperTest.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.github.caiiiycuk.pg2sqlite.dsl | ||
|
||
import com.github.caiiiycuk.pg2sqlite.iterator.Line | ||
import com.github.caiiiycuk.pg2sqlite.{Connection, DumpInserter} | ||
import org.scalatest.{BeforeAndAfter, FlatSpec, Matchers} | ||
|
||
import java.io.File | ||
|
||
class DumperTest extends FlatSpec with Matchers with BeforeAndAfter { | ||
|
||
val dbFile = new File("test.db") | ||
|
||
private def makeConnection() = { | ||
if (dbFile.exists()) { | ||
dbFile.delete() | ||
} | ||
|
||
Connection.sqlite(dbFile) | ||
} | ||
|
||
after { | ||
new File("test.db").delete() | ||
} | ||
|
||
"dumper" should "generate db from test-case of issue#11" in { | ||
val connection = makeConnection() | ||
val inserter = new DumpInserter(connection) | ||
val dump = | ||
""" | ||
|CREATE TYPE product_type AS ENUM ( | ||
| 'Material', | ||
| 'Digital' | ||
|); | ||
| | ||
|CREATE TABLE product ( | ||
| client_id integer NOT NULL, | ||
| order_product integer, | ||
| upper_price integer NOT NULL, | ||
| lower_price integer NOT NULL, | ||
| type product_type NOT NULL, | ||
| product_id integer NOT NULL--, | ||
| CONSTRAINT product_check CHECK (((lower_price > upper_price) AND (upper_price <= 200))), | ||
| CONSTRAINT product_order_product_check CHECK ((order_product > 0)), | ||
| CONSTRAINT product_upper_price_check CHECK ((upper_price >= 0)) | ||
|); | ||
|""".stripMargin | ||
.split("\n") | ||
.zipWithIndex | ||
.map { | ||
case (text, num) => | ||
Line(num, text) | ||
} | ||
|
||
inserter.insert(dump.iterator) | ||
connection.close | ||
} | ||
} |