mdneuzerling / lambdr

Run R containers on AWS Lambda
https://lambdr.mdneuzerling.com
Other
131 stars 12 forks source link

Test cases for input coming from API gateway #6

Closed mdneuzerling closed 3 years ago

mdneuzerling commented 3 years ago

The input to the Lambda when coming from an API gateway can be different to that coming from a direct invocation. There's some logic for this in the package already but it's untested. We need to create test cases with mocked APIs that cover this input. We need to consider also the situation in which there is no input, that is, there are no arguments to be passed to the handler function.

The logic for the event body parsing is found in parse_event_content in handle-event.R.

mdneuzerling commented 3 years ago

Interesting complication here. If the argument comes through as a query parameter, eg .../parity?number=9 then the arguments will be in the event body as queryStringParameters, eg. "queryStringParameters": {"number":[9]}. If they come through in the body, eg. .../parity -d '{"number": 9}' then they will appear as the body of the request.

Do we combine both?

Even stranger, the body in this case is a string of a JSON, rather than part of the event body JSON.

mdneuzerling commented 3 years ago

Resolved in 243396c67b9cde6ed7c14ee13ef5e491b7fe8108 but I'm concerned that there are some edge cases I've missed.