Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change assertResultFailed(f : =>, code: Int) to return ErrorResult #153

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
*.iml
12 changes: 8 additions & 4 deletions core/src/test/scala/validator-base.scala
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ class BaseValidatorSuite extends FunSuite {

}

def assertResultFailed(f : => Any, code : Int) : Unit = {
def assertResultFailed(f : => Any, code : Int) : ErrorResult = {
var result : ErrorResult = null
assertResultFailed(f).get.result match {
case other : ErrorResult =>
Expand All @@ -491,9 +491,10 @@ class BaseValidatorSuite extends FunSuite {
if (result.code != code) {
throw new TestFailedException(Some("Expected error code "+code+" but got "+result.code), None, 4)
}
return result
}

def assertResultFailed(f : => Any, code : Int, message : String) : Unit = {
def assertResultFailed(f : => Any, code : Int, message : String) : ErrorResult = {
var result : ErrorResult = null
assertResultFailed(f).get.result match {
case other : ErrorResult =>
Expand All @@ -506,9 +507,10 @@ class BaseValidatorSuite extends FunSuite {
if (result.message != message) {
throw new TestFailedException(Some("Expected error message '"+message+"' but got '"+result.message+"'"), None, 4)
}
return result
}

def assertResultFailed(f : => Any, code : Int, message : List[String]) : Unit = {
def assertResultFailed(f : => Any, code : Int, message : List[String]) : ErrorResult = {
var result : ErrorResult = null
assertResultFailed(f).get.result match {
case other : ErrorResult =>
Expand All @@ -523,9 +525,10 @@ class BaseValidatorSuite extends FunSuite {
throw new TestFailedException(Some("Expected error string '"+m+"' in the result message, but it didn't have one. Actual result message: '"+result.message+"'"), None, 4)
}
})
return result
}

def assertResultFailed(f : => Any, code : Int, headers : Map[String, String]) : Unit = {
def assertResultFailed(f : => Any, code : Int, headers : Map[String, String]) : ErrorResult = {
var result : ErrorResult = null
assertResultFailed(f).get.result match {
case other : ErrorResult =>
Expand All @@ -544,5 +547,6 @@ class BaseValidatorSuite extends FunSuite {
throw new TestFailedException(Some("Expected result header "+k+" to match value '"+v+"' but instead got '"+result.headers.get(k)+"'"), None, 4)
}
})
return result
}
}
4 changes: 3 additions & 1 deletion core/src/test/scala/validator-tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class ValidatorSuite extends BaseValidatorSuite {
}, assertConfig)

test ("GET on / should fail on validator_EMPTY") {
assertResultFailed(validator_EMPTY.validate(request("GET","/"),response,chain), 405, Map("Allow"->""))
val result = assertResultFailed(validator_EMPTY.validate(request("GET","/"),response,chain), 405, Map("Allow"->""))
// this is just a check to make sure the returned result has the same error code
assert(result.code == 405)
}

test ("an empty GET should fail on validator_EMPTY") {
Expand Down