-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
We have tests for static resources in the TCK now. The handlebars test was moved into the spock test-suite
- Loading branch information
Showing
9 changed files
with
57 additions
and
1,018 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
function-aws-api-proxy/src/test/groovy/io/micronaut/function/aws/proxy/HandlebarsSpec.groovy
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,57 @@ | ||
package io.micronaut.function.aws.proxy | ||
|
||
import com.amazonaws.serverless.proxy.internal.testutils.AwsProxyRequestBuilder | ||
import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext | ||
import com.amazonaws.services.lambda.runtime.Context | ||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.context.annotation.Requires | ||
import io.micronaut.core.util.CollectionUtils | ||
import io.micronaut.http.HttpHeaders | ||
import io.micronaut.http.HttpMethod | ||
import io.micronaut.http.MediaType | ||
import io.micronaut.http.annotation.Controller | ||
import io.micronaut.http.annotation.Get | ||
import io.micronaut.http.annotation.Produces | ||
import io.micronaut.views.ModelAndView | ||
import spock.lang.AutoCleanup | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
|
||
class HandlebarsSpec extends Specification { | ||
|
||
@Shared | ||
@AutoCleanup | ||
MicronautLambdaContainerHandler handler = new MicronautLambdaContainerHandler( | ||
ApplicationContext.builder().properties( | ||
'micronaut.security.enabled': false, | ||
'spec.name': 'HandlebarsSpec' | ||
) | ||
) | ||
@Shared | ||
Context lambdaContext = new MockLambdaContext() | ||
|
||
void "test handlebars view rendering"() { | ||
given: | ||
AwsProxyRequestBuilder builder = new AwsProxyRequestBuilder('/views/render-html', HttpMethod.GET.toString()) | ||
.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML) | ||
|
||
when: | ||
def response = handler.proxy(builder.build(), lambdaContext) | ||
|
||
then: | ||
response.statusCode == 200 | ||
response.body == '<html>Hello Luke Skywalker</html>' | ||
} | ||
|
||
@Controller('/views') | ||
@Requires(property = 'spec.name', value = 'HandlebarsSpec') | ||
static class BodyController { | ||
|
||
@Get("/render-html") | ||
@Produces(MediaType.TEXT_HTML) | ||
ModelAndView getHtmlFromRenderEngine(Context context) { | ||
ModelAndView mav = new ModelAndView("home", CollectionUtils.mapOf("firstname", "Luke", "lastname", "Skywalker")); | ||
mav; | ||
} | ||
} | ||
} |
16 changes: 0 additions & 16 deletions
16
function-aws-api-proxy/src/test/java/example/PingController.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
function-aws-api-proxy/src/test/java/example/StreamLambdaHandler.java
This file was deleted.
Oops, something went wrong.
207 changes: 0 additions & 207 deletions
207
...-aws-api-proxy/src/test/java/io/micronaut/function/aws/proxy/EchoMicronautController.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.