diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7a19d93 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +language: scala +scala: + - 2.10.0 + +#once develop is fixed we can turn this on +branches: + only: + - master +services: + - mysql + - posgres + - sqlite3 + +before_script: + - mysql -e 'create database dataexpress_test;' + - psql -c 'create database dataexpress_test;' -U postgres + +#Note that sbt needs the entire command quoted as well as quotes around the tags to exclude +script: + - sbt ++$TRAVIS_SCALA_VERSION 'test-only * -- -l "edu.chop.cbmi.dataExpress.test.util.tags.SqlServerTest edu.chop.cbmi.dataExpress.test.util.tags.OracleTest"' diff --git a/src/test/resources/mysql_travis_test.properties b/src/test/resources/mysql_travis_test.properties new file mode 100644 index 0000000..a78a832 --- /dev/null +++ b/src/test/resources/mysql_travis_test.properties @@ -0,0 +1,5 @@ +driverClassName=com.mysql.jdbc.Driver +jdbcUri=jdbc:mysql://127.0.0.1/dataexpress_test +user=travis +password= +jdbcCompliantTruncation=false diff --git a/src/test/resources/postgres_travis_test.properties b/src/test/resources/postgres_travis_test.properties new file mode 100644 index 0000000..bed8175 --- /dev/null +++ b/src/test/resources/postgres_travis_test.properties @@ -0,0 +1,4 @@ +driverClassName=org.postgresql.Driver +jdbcUri=dbc:postgresql://127.0.0.1/dataexpress_test +user=travis +password= diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/MySqlBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/MySqlBackendFeatureSpec.scala index cb02886..819ffbb 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/MySqlBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/MySqlBackendFeatureSpec.scala @@ -15,7 +15,7 @@ import java.util.Properties import edu.chop.cbmi.dataExpress.backends.MySqlBackend import edu.chop.cbmi.dataExpress.dataModels._ import edu.chop.cbmi.dataExpress.dataModels.sql._ -import edu.chop.cbmi.dataExpress.test.util.TestProps +import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.test.util.cars.dataSetup.backends.MySqlDataSetup import scala.language.reflectiveCalls diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala index 61df76e..aa29da6 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendFeatureSpec.scala @@ -10,18 +10,16 @@ package edu.chop.cbmi.dataExpress.test.backends -import org.scalatest.FeatureSpec +import org.scalatest.{FeatureSpec} import org.scalatest.matchers.ShouldMatchers import org.scalatest.GivenWhenThen -import java.util.Properties -import edu.chop.cbmi.dataExpress.test.util.TestProps +import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.dataModels._ import edu.chop.cbmi.dataExpress.dataModels.sql._ import edu.chop.cbmi.dataExpress.backends.OracleBackend import scala.language.reflectiveCalls import edu.chop.cbmi.dataExpress.test.util.cars.dataSetup.backends.OracleDataSetup - class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with ShouldMatchers { def fixture = @@ -29,7 +27,8 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul val props = TestProps.getDbProps("oracle") } - + //TODO: Hard-coding schema names and users in the tests like this is confusing. It's not clear how they relate to the properties file + //This stuff all needs to be re-worked val dbSchema:Option[String] = Some("QE10C01") val targetDbUserName:String = "QE10C01" @@ -73,7 +72,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - scenario("The user can create a table with four columns") { + scenario("The user can create a table with four columns", OracleTest) { val f = fixture val tableName = "cars_deba_a" @@ -144,7 +143,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - scenario("The user can truncate a table and commit") { + scenario("The user can truncate a table and commit", OracleTest) { val f = fixture val tableName:String = "cars_deba_a" @@ -182,9 +181,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - scenario("The inserted row can be committed by executing an insert query") { + scenario("The inserted row can be committed by executing an insert query", OracleTest) { val f = fixture val backend = new OracleBackend(f.props) val tableName = "cars_deba_a" @@ -224,8 +221,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - scenario("The user can obtain a record from executing a select query") { + scenario("The user can obtain a record from executing a select query", OracleTest) { //Prerequisites: scenario 1: Passed val f = fixture @@ -258,12 +254,8 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - - //THIS SHOULD WORK - scenario("The user can determine whether a select query has returned a record") { + scenario("The user can determine whether a select query has returned a record", OracleTest) { //Prerequisites: scenario 1: Passed val f = fixture @@ -304,13 +296,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - - scenario("The user can commit an open transaction") { + scenario("The user can commit an open transaction", OracleTest) { val f = fixture @@ -384,10 +370,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - scenario("The user can truncate a populated table") { + scenario("The user can truncate a populated table", OracleTest) { val f = fixture val tableName:String = "cars_deba_a" @@ -420,10 +403,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - scenario("The user can roll back an open transaction") { + scenario("The user can roll back an open transaction", OracleTest) { val f = fixture @@ -483,12 +463,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - scenario("The user can open a transaction, insert a row, and end the transaction") { + scenario("The user can open a transaction, insert a row, and end the transaction", OracleTest) { val f = fixture @@ -563,9 +538,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - scenario("The user can create a table with 32 columns") { + scenario("The user can create a table with 32 columns", OracleTest) { val f = fixture val tableName = "cars_deba_b" @@ -614,9 +587,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - scenario("The user can insert a row without constructing an insert statement") { + scenario("The user can insert a row without constructing an insert statement", OracleTest) { val f = fixture val tableName: String = "cars_deba_a" val columnNames: List[String] = List("carid", "carnumber", "carmake", "carmodel") @@ -651,13 +622,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - - scenario("The user can insert a batch of rows and commit without having to construct the insert statements") { + scenario("The user can insert a batch of rows and commit without having to construct the insert statements", OracleTest) { val f = fixture val tableName:String = "cars_deba_a" @@ -720,10 +685,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - scenario("The user can drop a table") { + scenario("The user can drop a table", OracleTest) { val f = fixture val tableName:String = "cars_deba_c" @@ -774,12 +736,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - scenario("The user can drop a table with cascade") { + scenario("The user can drop a table with cascade", OracleTest) { val f = fixture val tableName: String = "cars_deba_c" val viewName: String = "cars_deba_c_v" @@ -818,11 +775,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - scenario("The user can iterate over the results of a select query") { + scenario("The user can iterate over the results of a select query", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -854,10 +807,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - - scenario("The user can update a record in a table using a valid update statement") { + scenario("The user can update a record in a table using a valid update statement", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -916,8 +866,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - scenario("The user can update a multiple records in a table using a valid update statement") { + scenario("The user can update a multiple records in a table using a valid update statement", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -970,11 +919,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - - - scenario("The user can update a multiple records in a table without constructing update statement") { + scenario("The user can update a multiple records in a table without constructing update statement", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a with carmake = 'MiniCoopeRb' val f = fixture @@ -1033,11 +978,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul backend.close() } - - - - - scenario("The user can insert a multiple rows using a loop without constructing an insert statement") { + scenario("The user can insert a multiple rows using a loop without constructing an insert statement", OracleTest) { //Prerequisites: None of theses record should exist val f = fixture @@ -1090,11 +1031,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - scenario("The user can delete multiple records in a table using a valid delete statement") { + scenario("The user can delete multiple records in a table using a valid delete statement", OracleTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -1134,12 +1071,7 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - - - scenario("The user can drop all tables that begin with a certain string") { + scenario("The user can drop all tables that begin with a certain string", OracleTest) { /*http://stackoverflow.com/questions/3476765/mysql-drop-all-tables-ignoring-foreign-keys*/ @@ -1203,17 +1135,14 @@ class OracleBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Shoul } - - - - scenario("Remove Test Data Setup") { + scenario("Remove Test Data Setup", OracleTest) { /**** Remove Test Data ****/ removeTestDataSetup /**** ****/ } - scenario("Close Test SetUp Connections") { + scenario("Close Test SetUp Connections", OracleTest) { setup.targetBackend.close diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala index 0cb9770..d07d89a 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/OracleBackendSpec.scala @@ -1,15 +1,7 @@ package edu.chop.cbmi.dataExpress.backends.test -/** - * Created by IntelliJ IDEA. - * User: italiam - * Date: 11/22/11 - * Time: 1:22 PM - * To change this template use File | Settings | File Templates. - */ import org.scalatest.matchers.ShouldMatchers -import org.scalatest.{GivenWhenThen, Spec, FunSpec} -import java.util.Properties +import org.scalatest.{GivenWhenThen, FunSpec, Tag} import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.backends.OracleBackend import scala.language.reflectiveCalls @@ -25,23 +17,20 @@ class OracleBackendSpec extends FunSpec with ShouldMatchers with GivenWhenThen - it("should have a null connection to start") { + it("should have a null connection to start", OracleTest) { val backend = new OracleBackend(f.props) backend.connection should be (null) backend.close() } - it("should connect using a Properties object") { + it("should connect using a Properties object", OracleTest) { val backend = new OracleBackend(f.props) backend.connect() backend.connection should not be (null) backend.close() } - - - - it("should throw an exception if one of the properties isn't provided") { + it("should throw an exception if one of the properties isn't provided", OracleTest) { val badProps = f.props badProps.remove("jdbcUri") val backend = new OracleBackend(badProps) @@ -49,8 +38,7 @@ class OracleBackendSpec extends FunSpec with ShouldMatchers with GivenWhenThen backend.close() } - - it("should have a closed connection after it closes the connection") { + it("should have a closed connection after it closes the connection", OracleTest) { val newFixture = fixture val backend = new OracleBackend(newFixture.props) backend.connect() @@ -59,12 +47,6 @@ class OracleBackendSpec extends FunSpec with ShouldMatchers with GivenWhenThen backend.connection.isClosed() should be (true) } - - - - - - } } diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/PostgresBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/PostgresBackendFeatureSpec.scala index 8ba4d27..bb7d724 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/PostgresBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/PostgresBackendFeatureSpec.scala @@ -21,7 +21,7 @@ import edu.chop.cbmi.dataExpress.backends.PostgresBackend import edu.chop.cbmi.dataExpress.dataModels._ import edu.chop.cbmi.dataExpress.dataModels.sql._ -import edu.chop.cbmi.dataExpress.test.util.TestProps +import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.test.util.cars.dataSetup.backends.PostgresDataSetup import scala.language.reflectiveCalls diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala index 3404532..652ab16 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendFeatureSpec.scala @@ -1,9 +1,8 @@ package edu.chop.cbmi.dataExpress.test.backends -import org.scalatest.FeatureSpec +import org.scalatest.{Tag, FeatureSpec, GivenWhenThen} import org.scalatest.matchers.ShouldMatchers -import org.scalatest.GivenWhenThen import edu.chop.cbmi.dataExpress.backends.SqlServerBackend import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.dataModels._ @@ -11,7 +10,6 @@ import edu.chop.cbmi.dataExpress.dataModels.sql._ import edu.chop.cbmi.dataExpress.dataModels.sql.IntegerDataType import scala.language.reflectiveCalls - class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with ShouldMatchers { def fixture = @@ -40,7 +38,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - scenario("The user can create a table with four columns") { + scenario("The user can create a table with four columns", SqlServerTest) { val f = fixture val tableName = "cars_deba_a" val columnFixedWidth: Boolean = false @@ -83,9 +81,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - - scenario("The user can truncate a table and commit") { + scenario("The user can truncate a table and commit", SqlServerTest) { val f = fixture val tableName: String = "cars_deba_a" val countStatement: String = """select count(*) as 'count' from """ + tableName @@ -108,10 +104,8 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - //TODO: This test needs to be re-written with an auto-incrementing sequence in the table to fully test insert returning keys - scenario("The inserted row can be committed") { + scenario("The inserted row can be committed", SqlServerTest) { val f = fixture val backend = new SqlServerBackend(f.props) val tableName = "cars_deba_a" @@ -150,9 +144,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - - scenario("The user can obtain a record from executing a select query") { + scenario("The user can obtain a record from executing a select query", SqlServerTest) { //Prerequisites: ignore 1: Passed val f = fixture @@ -178,7 +170,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - scenario("The user can determine whether a select query has returned a record") { + scenario("The user can determine whether a select query has returned a record", SqlServerTest) { //Prerequisites: ignore 1: Passed @@ -206,8 +198,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - scenario("The user can commit an open transaction") { + scenario("The user can commit an open transaction", SqlServerTest) { val f = fixture var backend = new SqlServerBackend(f.props) @@ -248,8 +239,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can truncate a populated table") { + scenario("The user can truncate a populated table", SqlServerTest) { val f = fixture val tableName = "cars_deba_a" val countStatement = "select count(1) as 'count' from %s".format(tableName) @@ -274,8 +264,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - scenario("The user can roll back an open transaction") { + scenario("The user can roll back an open transaction", SqlServerTest) { val f = fixture val backend = new SqlServerBackend(f.props) val tableName = "cars_deba_a" @@ -321,8 +310,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - scenario("The user can open a transaction, insert a row, and end the transaction") { + scenario("The user can open a transaction, insert a row, and end the transaction", SqlServerTest) { val f = fixture val backend = new SqlServerBackend(f.props) @@ -375,8 +363,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - scenario("The user can create a table with 32 columns") { + scenario("The user can create a table with 32 columns", SqlServerTest) { val f = fixture val tableName = "cars_deba_b" val columnFixedWidth:Boolean = false @@ -410,8 +397,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can insert a row without constructing an insert statement") { + scenario("The user can insert a row without constructing an insert statement", SqlServerTest) { val f = fixture val tableName = "cars_deba_a" val columnNames = List("carid","carnumber","carmake","carmodel") @@ -448,7 +434,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - scenario("The user can insert a batch of rows and commit without having to construct the insert statements") { + scenario("The user can insert a batch of rows and commit without having to construct the insert statements", SqlServerTest) { val f = fixture val tableName = "cars_deba_a" val columnNames = List("carid","carnumber","carmake","carmodel") @@ -488,7 +474,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - scenario("The user can drop a table") { + scenario("The user can drop a table", SqlServerTest) { val f = fixture val tableName = "cars_deba_c" val columnFixedWidth = false @@ -521,7 +507,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } //Cascade on drop table is unsupported in sql server - scenario("The user gets an exception when trying to drop a table with cascade") { + scenario("The user gets an exception when trying to drop a table with cascade", SqlServerTest) { val f = fixture val tableName = "cars_deba_c" val viewName = "cars_deba_c_v" @@ -553,7 +539,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - scenario("The user can iterate over the results of a select query") { + scenario("The user can iterate over the results of a select query", SqlServerTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture val backend = new SqlServerBackend(f.props) @@ -579,7 +565,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - scenario("The user can update a record in a table using a valid update statement") { + scenario("The user can update a record in a table using a valid update statement", SqlServerTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -615,8 +601,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can update a multiple records in a table using a valid update statement") { + scenario("The user can update a multiple records in a table using a valid update statement", SqlServerTest) { //Prerequisites: Need Multiple Row in table cars_deba_a val f = fixture @@ -652,8 +637,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can update a multiple records in a table without constructing update statement") { + scenario("The user can update a multiple records in a table without constructing update statement", SqlServerTest) { //Prerequisites: Need Multiple Row in table cars_deba_a with carmake = 'MiniCoopeRb' val f = fixture @@ -692,8 +676,7 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh backend.close() } - - scenario("The user can insert a multiple rows using a loop without constructing an insert statement") { + scenario("The user can insert a multiple rows using a loop without constructing an insert statement", SqlServerTest) { //Prerequisites: None of theses record should exist val f = fixture val tableName = "cars_deba_a" @@ -728,22 +711,16 @@ class SqlServerBackendFeatureSpec extends FeatureSpec with GivenWhenThen with Sh } - - - scenario("Remove Test Data Setup") { + scenario("Remove Test Data Setup", SqlServerTest) { /**** Remove Test Data ****/ removeTestDataSetup /**** ****/ } - scenario("Close Test SetUp Connections") { + scenario("Close Test SetUp Connections", SqlServerTest) { setup.targetBackend.close } - - - - } diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendSpec.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendSpec.scala index 3a0f2d1..0553855 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendSpec.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/backends/SqlServerBackendSpec.scala @@ -6,6 +6,7 @@ import edu.chop.cbmi.dataExpress.test.util._ import edu.chop.cbmi.dataExpress.backends.SqlServerBackend import scala.language.reflectiveCalls + class SqlServerBackendSpec extends FunSpec with ShouldMatchers { def fixture = @@ -17,20 +18,20 @@ class SqlServerBackendSpec extends FunSpec with ShouldMatchers { - it("should have a null connection to start") { + it("should have a null connection to start", SqlServerTest) { val backend = new SqlServerBackend(f.props) backend.connection should be (null) backend.close() } - it("should connect using a Properties object") { + it("should connect using a Properties object", SqlServerTest) { val backend = new SqlServerBackend(f.props) backend.connect() backend.connection should not be (null) backend.close() } - it("should throw an exception if one of the properties isn't provided") { + it("should throw an exception if one of the properties isn't provided", SqlServerTest) { val badProps = f.props badProps.remove("jdbcUri") val backend = new SqlServerBackend(badProps) @@ -39,7 +40,7 @@ class SqlServerBackendSpec extends FunSpec with ShouldMatchers { } - it("should have a closed connection after it closes the connection") { + it("should have a closed connection after it closes the connection", SqlServerTest) { val newFixture = fixture val backend = new SqlServerBackend(newFixture.props) backend.connect() diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala index 5fc6d4f..013fcad 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/tutorial/Tutorial.scala @@ -1,7 +1,5 @@ package edu.chop.cbmi.dataExpress.test.tutorial -import org.scalatest.junit.JUnitRunner -import org.scalatest.FeatureSpec import org.scalatest.matchers.ShouldMatchers import org.scalatest.GivenWhenThen import java.util.{UUID, Properties} @@ -9,8 +7,6 @@ import java.io.File import edu.chop.cbmi.dataExpress.backends._ import edu.chop.cbmi.dataExpress.dataModels._ import edu.chop.cbmi.dataExpress.dataModels.sql._ -import edu.chop.cbmi.dataExpress.dsl._ -import edu.chop.cbmi.dataExpress.dsl.stores.SqlDb import edu.chop.cbmi.dataExpress.dsl.ETL._ import edu.chop.cbmi.dataExpress.dsl.ETL import edu.chop.cbmi.dataExpress.dsl.stores.SqlDb @@ -22,6 +18,7 @@ import org.scalatest.FlatSpec */ + class TutorialFeatureSpec extends FlatSpec with GivenWhenThen with ShouldMatchers { "The setup" should "be able to take a clean database and create the necessary tables" in withBlankDatabase {db => diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/util/Tags.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/util/Tags.scala new file mode 100644 index 0000000..527540d --- /dev/null +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/util/Tags.scala @@ -0,0 +1,6 @@ +package edu.chop.cbmi.dataExpress.test.util + +import org.scalatest.Tag + +object OracleTest extends Tag("edu.chop.cbmi.dataExpress.test.util.tags.OracleTest") +object SqlServerTest extends Tag("edu.chop.cbmi.dataExpress.test.util.tags.SqlServerTest") \ No newline at end of file diff --git a/src/test/scala/edu/chop/cbmi/dataExpress/test/util/TestProps.scala b/src/test/scala/edu/chop/cbmi/dataExpress/test/util/TestProps.scala index 5f7dfb9..8f35af3 100644 --- a/src/test/scala/edu/chop/cbmi/dataExpress/test/util/TestProps.scala +++ b/src/test/scala/edu/chop/cbmi/dataExpress/test/util/TestProps.scala @@ -22,6 +22,25 @@ object TestProps { } private def choosePropFile(dbname: String) = { + val travis = System.getenv("TRAVIS") + + travis match { + case "true"=> getTravisDbProps(dbname) + case _ => getLocalDbProps(dbname) + } + + } + + private def getTravisDbProps(dbname: String) = { + dbname match { + case "mysql" => "/mysql_travis_test.properties" + case "postgres" => "/postgres_travis_test.properties" + case "sqlite" => "/sqlite_test.properties" + case _ => "/%s_travis_test.properties".format(dbname) + + } + } + private def getLocalDbProps(dbname: String) = { dbname match { case "mysql" => "/mysql_test.properties" case "postgres" => "/postgres_test.properties" @@ -29,8 +48,10 @@ object TestProps { case "sqlserver" => "/sqlserver_test.properties" case _ => "/%s_test.properties".format(dbname) } + } + def connectToDB(sb : SqlBackend) = { sb.connect sb