Skip to content

Commit

Permalink
add PackageTest for routes
Browse files Browse the repository at this point in the history
  • Loading branch information
fluency03 committed Apr 30, 2018
1 parent 88e11b8 commit e1ba541
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.fluency03.blockchain.api.routes

import akka.http.scaladsl.model.StatusCodes
import com.fluency03.blockchain.api.{FailureMsg, SuccessMsg}
import org.scalatest.{FlatSpec, Matchers}

class PackageTest extends FlatSpec with Matchers {

"failsafeMsg" should "return corresponding message based on success/failure of the function." in {
failsafeMsg({
throw new Exception("some error")
"some string"
}) shouldEqual FailureMsg("some error")

failsafeMsg({
"some string"
}) shouldEqual SuccessMsg("some string")

}

"failsafeResp" should "return corresponding message based on success/failure of the function." in {
failsafeResp({
throw new Exception("some error")
"some string"
}) shouldEqual (StatusCodes.InternalServerError, FailureMsg("some error"))

failsafeResp({
"some string"
}) shouldEqual (StatusCodes.OK, SuccessMsg("some string"))

}

}

0 comments on commit e1ba541

Please sign in to comment.