Permalink
Browse files

Fix compile error if postgres is not enable in test-dbs

  • Loading branch information...
1 parent f632d10 commit e53c400c0edf4fb24f55009564e2885ecb7e2712 @AtkinsChang AtkinsChang committed Aug 1, 2016
@@ -1,5 +1,5 @@
-DROP TABLE IF EXISTS "test";
-CREATE TABLE "test" ("smallint_auto_inc" SMALLSERIAL,
+DROP TABLE IF EXISTS "test_default";
+CREATE TABLE "test_default" ("smallint_auto_inc" SMALLSERIAL,
"smallint_no_default" SMALLINT,
"smallint_default_zero" SMALLINT DEFAULT 0,
"smallint_default_pos" SMALLINT DEFAULT 1,
@@ -104,7 +104,32 @@ val SimpleA = CustomTyping.SimpleA
""".stripMargin
},
new UUIDConfig("Postgres2", StandardTestDBs.Postgres, "Postgres", Seq("/dbs/uuid-postgres.sql")),
- new Config("Postgres3", StandardTestDBs.Postgres, "Postgres", Seq("/dbs/postgres.sql")),
+ new Config("Postgres3", StandardTestDBs.Postgres, "Postgres", Seq("/dbs/postgres.sql")) {
+ override def testCode: String =
+ """import slick.ast.{FieldSymbol, Select}
+ |import slick.jdbc.meta.MTable
+ |import slick.relational.RelationalProfile
+ |DBIO.seq(
+ | schema.create,
+ | MTable.getTables(Some(""), Some("public"), None, None).map { tables =>
+ | def optionsOfColumn(c: slick.lifted.Rep[_]) =
+ | c.toNode.asInstanceOf[Select].field.asInstanceOf[FieldSymbol].options.toList
+ | val smallserialOptions = optionsOfColumn(TestDefault.baseTableRow.smallintAutoInc)
+ | val serialOptions = optionsOfColumn(TestDefault.baseTableRow.intAutoInc)
+ | val bigserialOptions = optionsOfColumn(TestDefault.baseTableRow.bigintAutoInc)
+ | val char1EmptyOptions = optionsOfColumn(TestDefault.baseTableRow.char1DefaultEmpty)
+ | val char1ValidOptions = optionsOfColumn(TestDefault.baseTableRow.char1DefaultValid)
+ | val char1InvalidOptions = optionsOfColumn(TestDefault.baseTableRow.char1DefaultInvalid)
+ | assertTrue("smallint_auto_inc should be AutoInc", smallserialOptions.exists(option => (option equals TestDefault.baseTableRow.O.AutoInc)))
+ | assertTrue("int_auto_inc should be AutoInc", serialOptions.exists(option => (option equals TestDefault.baseTableRow.O.AutoInc)))
+ | assertTrue("bigint_auto_inc should be AutoInc", bigserialOptions.exists(option => (option equals TestDefault.baseTableRow.O.AutoInc)))
+ | assertTrue("default value of char1_default_empty should be ' '", char1EmptyOptions.exists(option => (option equals TestDefault.baseTableRow.O.Default(Some(' ')))))
+ | assertTrue("default value of char1_default_valid should be 'a'", char1ValidOptions.exists(option => (option equals TestDefault.baseTableRow.O.Default(Some('a')))))
+ | assertTrue("default value of char1_default_invalid should not exist", char1InvalidOptions.forall(option => (option.isInstanceOf[RelationalProfile.ColumnOption.Default[_]])))
+ | }
+ |)
+ """.stripMargin
+ },
new Config("EmptyDB", StandardTestDBs.H2Mem, "H2Mem", Nil),
new Config("Oracle1", StandardTestDBs.Oracle, "Oracle", Seq("/dbs/oracle1.sql")) {
override def useSingleLineStatements = true
@@ -7,7 +7,6 @@ import slick.jdbc.meta.MTable
import slick.test.codegen.generated._
import com.typesafe.slick.testkit.util.{TestCodeRunner, JdbcTestDB}
import org.junit.Assert._
-import slick.relational.RelationalProfile
/** Test files generated by CodeGeneratorTest */
class GeneratedCodeTest extends TestCodeRunner(AllTests)
@@ -135,30 +134,6 @@ object GeneratedCodeTest {
)
}
- def testPostgres3 = {
- import Postgres3._
- import profile.api._
- DBIO.seq(
- schema.create,
- MTable.getTables(Some(""), Some("public"), None, None).map { tables =>
- def optionsOfColumn(c: slick.lifted.Rep[_]) =
- c.toNode.asInstanceOf[Select].field.asInstanceOf[FieldSymbol].options.toList
- val smallserialOptions = optionsOfColumn(Test.baseTableRow.smallintAutoInc)
- val serialOptions = optionsOfColumn(Test.baseTableRow.intAutoInc)
- val bigserialOptions = optionsOfColumn(Test.baseTableRow.bigintAutoInc)
- val char1EmptyOptions = optionsOfColumn(Test.baseTableRow.char1DefaultEmpty)
- val char1ValidOptions = optionsOfColumn(Test.baseTableRow.char1DefaultValid)
- val char1InvalidOptions = optionsOfColumn(Test.baseTableRow.char1DefaultInvalid)
- assertTrue("smallint_auto_inc should be AutoInc", smallserialOptions.exists(option => (option equals Test.baseTableRow.O.AutoInc)))
- assertTrue("int_auto_inc should be AutoInc", serialOptions.exists(option => (option equals Test.baseTableRow.O.AutoInc)))
- assertTrue("bigint_auto_inc should be AutoInc", bigserialOptions.exists(option => (option equals Test.baseTableRow.O.AutoInc)))
- assertTrue("default value of char1_default_empty should be ' '", char1EmptyOptions.exists(option => (option equals Test.baseTableRow.O.Default(Some(' ')))))
- assertTrue("default value of char1_default_valid should be 'a'", char1ValidOptions.exists(option => (option equals Test.baseTableRow.O.Default(Some('a')))))
- assertTrue("default value of char1_default_invalid should not exist", char1InvalidOptions.forall(option => (option.isInstanceOf[RelationalProfile.ColumnOption.Default[_]])))
- }
- )
- }
-
def testEmptyDB = slick.dbio.DBIO.successful(())
def tableName( node:Node ) : String = {

0 comments on commit e53c400

Please sign in to comment.