Skip to content

Commit

Permalink
add in some simple tests, they are not good tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfun committed Oct 26, 2018
1 parent 605dee7 commit 145fe74
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/main/scala/gs/nick/ApiHandler.scala
Expand Up @@ -8,6 +8,10 @@ import scala.concurrent.Future

object BirdsDao {
var all: IndexedSeq[Bird] = IndexedSeq.empty

def reset(): Unit = {
all = IndexedSeq.empty
}
}


Expand Down Expand Up @@ -39,6 +43,10 @@ class BirdsController extends BirdsHandler {

object SightingsDao {
var all: IndexedSeq[Sighting] = IndexedSeq.empty

def reset(): Unit = {
all = IndexedSeq.empty
}
}

class SightingsController extends SightingsHandler {
Expand Down
27 changes: 24 additions & 3 deletions src/test/scala/samples/junit.scala
Expand Up @@ -2,19 +2,40 @@ package samples


import scala.concurrent.duration.Duration

import org.junit._
import Assert._
import gs.nick.server.birds.BirdsResource
import gs.nick.server.definitions.{Bird, Sighting}
import gs.nick.server.sightings.SightingsResource
import gs.nick.{BirdsController, BirdsDao, SightingsController, SightingsDao}

import scala.concurrent.Await

@Test
class AppTest {


@Before
def setup(): Unit = {
BirdsDao.reset()
SightingsDao.reset()
}

@Test
def testAddBirds(): Unit = {
val controller = new BirdsController
assertTrue(BirdsDao.all.isEmpty)
controller.addBird(BirdsResource.addBirdResponse)(Bird(1, "blue jay", "sings a lot"))
controller.addBird(BirdsResource.addBirdResponse)(Bird(2, "crow", "ugly"))
assertTrue(BirdsDao.all.length == 2)
}

@Test
def testAddGame() = {
assertTrue(true)
def testAddSighting(): Unit = {
val controller = new SightingsController
assertTrue(SightingsDao.all.isEmpty)
controller.addSighting(SightingsResource.addSightingResponse)(Sighting(1, 1, "2017-09-14", "saw a blue jay this morning"))
controller.addSighting(SightingsResource.addSightingResponse)(Sighting(2, 1, "2018-01-03", "At the park in Hayward"))
}

}
Expand Down

0 comments on commit 145fe74

Please sign in to comment.