Reputation: 1195
I have a Quarkus project with a few different Lambda handlers.
In order to 'deploy' or 'select' the handler to use, the documentation states that we should set the quarkus.lambda.handler
application.properties setting, or QUARKUS_LAMBDA_HANDLER
environment variable accordingly.
E.g.
quarkus.lambda.handler=my-handler
The handler is named with the @Named
annotation. E.g.
@Named("my-handler")
The application.properties setting or environment variable works for selecting a single handler for testing purposes, but I run into trouble when trying to test multiple handlers in one go in the project.
I've tried using a System property to set quarkus.lambda.handler
in the hopes that it would override the setting, and also tried modifying the live JVM system environment variables using my test setup method (@BeforeAll
), however I think that the test run caches environment variables at the start, and so modifying things during a test session doesn't work.
Is there a known or valid way to test multiple quarkus lambda function handlers in a project without having to edit the application.properties file each time I want to test a different handler?
Upvotes: 7
Views: 1048
Reputation: 31
If I understood correctly your problem you could use QuarkusTestProfile
just implements this interface and return something like this
@Override
public Map<String, String> getConfigOverrides() {
return Map.of("quarkus.lambda.handler", "name-of-the-handler");
}
After this annotate your test with @TestProfile(ClassImplementingQuarkusTestProfile)
and this should be enough to let you run it.
Unfortunately after you have multiple handlers you have to set the TestProfile for all the tests.
Upvotes: 3