Skip to content

Commit

Permalink
Test rework to cover more database/driver versions / #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Apr 6, 2018
1 parent f2e69cb commit 5b38155
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ task mysql56Test(type: Test) {
// composeUp.execute()
// exposedDialectTestWithDocker.execute()
println "MYSQL"
// environment 'DB_VERSION' "5.6"
project.setProperty('db_version', '5.6')
// env
}

dockerCompose {
// def dialectProp = System.getProperty("dialect", "")
// println dialectProp
// println ext.dialect
mysql {
environment.put 'DB_VERSION', '5.6'

mysql {
environment.put 'DB_VERSION', project.property('db_version')
useComposeFiles = ['src/test-conf/compose/docker-compose-mysql.yml']
isRequiredBy(project.tasks.mysql56Test)
}
Expand Down Expand Up @@ -117,6 +118,7 @@ dependencies {

test {
jvmArgs "-XX:MaxPermSize=256m"

testLogging {
events "PASSED", "FAILED", "SKIPPED"
showStandardStreams = true
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ group=org.jetbrains.exposed
version=0.10.3-SNAPSHOT
kotlin_version=1.2.30
spring_version=4.3.7.RELEASE
dialect=custom
dialect=custom
db_version=
2 changes: 2 additions & 0 deletions src/test-conf/compose/docker-compose-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ version: '3.5'
services:
mysql:
image: "mysql:${DB_VERSION:-latest}"
ports:
- "3306:3306"
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
13 changes: 12 additions & 1 deletion src/test-conf/mysql56.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
dependencies {
"mysql:mysql-connector-java:5.1.44"
}
}

mysql56Test.doFirst {
println('INIT')
//tasks.withType(Test) {
// def containerInfo = dockerCompose.servicesInfos['mysql']
def url = "jdbc:mysql://localhost:3306" //+ containerInfo.host + ':' + containerInfo.ports['3306']
systemProperty 'exposed.test.dialects', dialect
systemProperty 'exposed.test.custom.dialect', 'mysql'
systemProperty 'exposed.test.custom.driver', 'com.mysql.jdbc.Driver'
systemProperty 'exposed.test.custom.url', url
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ enum class TestDB(val connection: String, val driver: String, val user: String =

CUSTOM(System.getProperty("exposed.test.custom.url", ""),
System.getProperty("exposed.test.custom.driver", ""),
System.getProperty("exposed.test.custom.user", ""),
System.getProperty("exposed.test.custom.pass", "")
System.getProperty("exposed.test.custom.user", "root"),
System.getProperty("exposed.test.custom.pass", "password")
);

fun connect() = Database.connect(connection, user = user, password = pass, driver = driver).also { db ->
Expand All @@ -73,7 +73,7 @@ enum class TestDB(val connection: String, val driver: String, val user: String =

companion object {
fun enabledInTests(): List<TestDB> {
val embeddedTests = (TestDB.values().toList() - ORACLE - SQLSERVER).joinToString()
val embeddedTests = (TestDB.values().toList() - ORACLE - SQLSERVER - CUSTOM).joinToString()
val concreteDialects = System.getProperty("exposed.test.dialects", embeddedTests).let {
if (it == "") emptyList()
else it.split(',').map { it.trim().toUpperCase() }
Expand Down

0 comments on commit 5b38155

Please sign in to comment.