Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -199,7 +199,7 @@ class IntegrationSpec extends Spec {
}
}
}

"execute an update via a prepared statement" in {
if (postgresAvailable) {
val client = getClient
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down