diff --git a/src/test/scala/com/twitter/finagle/postgres/integration/IntegrationSpec.scala b/src/test/scala/com/twitter/finagle/postgres/integration/IntegrationSpec.scala index 1e28cb8e..a3b6b3a8 100644 --- a/src/test/scala/com/twitter/finagle/postgres/integration/IntegrationSpec.scala +++ b/src/test/scala/com/twitter/finagle/postgres/integration/IntegrationSpec.scala @@ -7,9 +7,9 @@ import com.twitter.finagle.postgres.{Row, OK, Spec, Client} import com.twitter.util.{Duration, Await} object IntegrationSpec { - val pgHostPort = "localhost:5432" - val pgUser = "finagle_tester" - val pgPassword = "abc123" + val pgHostPort = sys.env.get("PGHOSTPORT").getOrElse("localhost:5432") + val pgUser = sys.env.get("PGUSER").getOrElse("finagle_tester") + val pgPassword = sys.env.get("PGPASS").getOrElse("abc123") val pgDbName = "finagle_postgres_test" val pgTestTable = "finagle_test" @@ -199,7 +199,7 @@ class IntegrationSpec extends Spec { } } } - + "execute an update via a prepared statement" in { if (postgresAvailable) { val client = getClient @@ -211,15 +211,15 @@ class IntegrationSpec extends Spec { "UPDATE %s SET str_field = $1 where int_field = 4567".format(IntegrationSpec.pgTestTable), "hello_updated" ) - + val numRows = Await.result(preparedQuery) - - val resultRows = Await.result(client.select("SELECT * from %s WHERE str_field = 'hello_updated' AND int_field = 4567")(identity)) + + val resultRows = Await.result(client.select("SELECT * from %s WHERE str_field = 'hello_updated' AND int_field = 4567".format(IntegrationSpec.pgTestTable))(identity)) resultRows.size must equal(numRows) } } - + "return rows from UPDATE...RETURNING" in { if (postgresAvailable) { val client = getClient @@ -231,14 +231,14 @@ class IntegrationSpec extends Spec { "UPDATE %s SET str_field = $1 where int_field = 4567 RETURNING *".format(IntegrationSpec.pgTestTable), "hello_updated" )(identity) - + val resultRows = Await.result(preparedQuery) resultRows.size must equal(1) resultRows(0).get[String]("str_field") must equal("hello_updated") } } - + "return rows from DELETE...RETURNING" in { if (postgresAvailable) { val client = getClient @@ -249,14 +249,14 @@ class IntegrationSpec extends Spec { val preparedQuery = client.prepareAndQuery( "DELETE FROM %s where int_field = 4567 RETURNING *".format(IntegrationSpec.pgTestTable) )(identity) - + val resultRows = Await.result(preparedQuery) resultRows.size must equal(1) - resultRows(0).get[String]("str_field") must equal("hello") + resultRows(0).get[String]("str_field") must equal("goodbye") } } - + "execute an UPDATE...RETURNING that updates nothing" in { if (postgresAvailable) { val client = getClient @@ -269,13 +269,13 @@ class IntegrationSpec extends Spec { "hello_updated", "xxxx" )(identity) - + val resultRows = Await.result(preparedQuery) resultRows.size must equal(0) } } - + "execute a DELETE...RETURNING that deletes nothing" in { if (postgresAvailable) { val client = getClient @@ -287,7 +287,7 @@ class IntegrationSpec extends Spec { "DELETE FROM %s WHERE str_field=$1".format(IntegrationSpec.pgTestTable), "xxxx" )(identity) - + val resultRows = Await.result(preparedQuery) resultRows.size must equal(0)