-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for Handler, and correct failing test
- Loading branch information
1 parent
206f47a
commit f235d4f
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package cql | ||
|
||
import org.scalatest.matchers._ | ||
import org.scalatest.funspec.AnyFunSpec | ||
import cql.lang.BaseTest | ||
import com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent | ||
|
||
class HandlerTest extends AnyFunSpec with should.Matchers { | ||
val handler = new Handler() | ||
|
||
def assertIO(input: String, status: Int, output: String) = | ||
val request = new APIGatewayProxyRequestEvent().withBody(input) | ||
|
||
val response = handler.handleRequest(request, null) | ||
|
||
response.getBody.contains(output) shouldBe true | ||
|
||
describe("a program") { | ||
it("should give a 200 for a valid query") { | ||
assertIO("+section:commentisfree", 200, "section=commentisfree") | ||
} | ||
|
||
it("should give a 400 for an invalid query") { | ||
assertIO("this AND", 200, "There must be a query following 'AND', e.g. this AND that.") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters