Add ability to configure postgres database backends for test cases via reference.conf (#3421)

This commit is contained in:
Chris Stewart 2021-07-19 09:55:36 -05:00 committed by GitHub
parent 7f07ed7a7a
commit b2b2ca45db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 1 deletions

View File

@ -164,6 +164,13 @@ bitcoin-s {
name = testdb
}
}
testkit {
pg {
#enabled postgres backend database for all test cases
enabled = false
}
}
}
akka {

View File

@ -277,6 +277,13 @@ bitcoin-s {
path = ${bitcoin-s.datadir}/oracle/
}
}
testkit {
pg {
#enabled postgres backend database for all test cases
enabled = false
}
}
}

View File

@ -142,6 +142,13 @@ bitcoin-s {
password = ""
}
}
testkit {
pg {
#enabled postgres backend database for all test cases
enabled = false
}
}
}

View File

@ -1,11 +1,24 @@
package org.bitcoins.testkit
import com.opentable.db.postgres.embedded.EmbeddedPostgres
import com.typesafe.config.ConfigFactory
import org.scalatest.{BeforeAndAfterAll, Suite}
trait EmbeddedPg extends BeforeAndAfterAll { this: Suite =>
lazy val pgEnabled: Boolean = sys.env.contains("PG_ENABLED")
lazy val pgEnabled: Boolean = {
val config = ConfigFactory.load()
val isEnv = sys.env.contains("PG_ENABLED")
val isConfig = {
if (config.hasPath("bitcoin-s.testkit.pg.enabled")) {
config.getBoolean("bitcoin-s.testkit.pg.enabled")
} else {
false
}
}
val isPgEnabled = isEnv || isConfig
isPgEnabled
}
lazy val pg: Option[EmbeddedPostgres] = {