Note that there are some explanatory texts on larger screens.

plurals
  1. POPlayframework tests pass in Intellij but not in play console
    primarykey
    data
    text
    <p>I have a Simple insert and update test for a table: </p> <pre><code> case class Player(id: UUID, name: String, email: String) </code></pre> <p>with all the appropriate setup in a model object for performing inserts and finds. </p> <p>Running the following test: </p> <pre><code>class PlayerSpec extends Specification { "Player" should { val application = FakeApplication(additionalConfiguration = inMemoryDatabase("test")) "insert a player" in { running(application) { val uuid = UUID.randomUUID() Player.insert(Player(uuid, "Joe Person", "joe.player@someplace.mail")) must beEqualTo(1) } } "Find a player by id" in { running(application) { val uuid = UUID.randomUUID() Player.insert(Player(uuid, "Jane Person", "jane.player@someplace.mail")) Player.findById(uuid) must beEqualTo(Some(Player(uuid, "Jane Person", "jane.player@someplace.mail"))) } } } } </code></pre> <p>I get a green bar in Intellij (both examples pass). However, when I run this in the play console I get the following error:</p> <pre><code>[info] PlayerSpec [info] [info] Player should [info] + insert a player [error] ! Find a player by id [error] anon$1: Configuration error [Cannot connect to database [default]] Configuration.scala:258) .... </code></pre> <p>Is this a configuration issue, or am I missing some sort of a beforeEach type call?</p> <p><strong>EDIT</strong></p> <p>Just adding the db code, for more reference</p> <pre><code>case class Player(id: UUID, name: String, email: String) object Player { private val fullPlayer = { get[UUID]("player.id")(Utils.rowToUuid) ~ get[String]("player.name") ~ get[String]("player.email") map { case id~name~email =&gt; Player(id, name, email) } } def insert(player: Player) = { DB.withConnection { implicit c =&gt; SQL( """ insert into player (id, name, email) values ( {id}, {name}, {email} ) """ ).on( 'id -&gt; player.id.toString, 'name -&gt; player.name, 'email -&gt; player.email ).executeUpdate() } } def findById(id: UUID) : Option[Player] = { DB.withConnection { implicit c =&gt; SQL("select * from player where id = {id}").on('id -&gt; id).as(fullPlayer.singleOpt) } } } </code></pre> <p>rowToUUID:</p> <pre><code>object Utils { implicit def rowToUuid: Column[UUID] = Column.nonNull { (value, meta) =&gt; val MetaDataItem(qualified, nullable, clazz) = meta value match { case uuid: UUID =&gt; Right(uuid) case _ =&gt; Left(TypeDoesNotMatch("Cannot convert " + value + ":" + value.asInstanceOf[AnyRef].getClass + " to UUID for column " + qualified)) } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload