Files
floci/compatibility-tests/sdk-test-awscli/test/lambda.bats
T
Yorí 8eeb2244a7 Feat/lambda image config working directory (#673)
* feat(lambda): support ImageConfig.WorkingDirectory override

Propagate WorkingDirectory from the Lambda ImageConfig through the full
stack so container images that rely on a specific WORKDIR can be invoked
correctly, matching real AWS behavior.

- LambdaFunction: add imageConfigWorkingDirectory field + getter/setter
- LambdaService: parse WorkingDirectory on CreateFunction and
  UpdateFunctionConfiguration
- ContainerSpec: add workingDir record component
- ContainerBuilder: add withWorkingDir() fluent method
- ContainerLifecycleManager: pass workingDir to Docker via withWorkingDir()
- ContainerLauncher: apply workingDir when building the container spec
- LambdaController: serialize WorkingDirectory in ImageConfigResponse

* test(lambda): add tests for ImageConfig.WorkingDirectory

Unit tests (LambdaImageConfigTest):
- CreateFunction stores WorkingDirectory alongside Command/EntryPoint
- createFunction with all three fields together
- updateFunctionConfiguration updates and clears WorkingDirectory
- ContainerLauncher passes workingDir to ContainerSpec

Compat tests across all SDKs:
- awscli (lambda.bats): create/get/update WorkingDirectory round-trip
- Java SDK (LambdaFunctionConfigTest): ImageConfig.WorkingDirectory round-trip
- Python (test_lambda_function_config.py): TestImageConfigWorkingDirectory class
- Node (lambda.test.ts): create/update WorkingDirectory assertions
- Go (lambda_test.go): TestLambdaImageConfigWorkingDirectory subtests
- Rust (lambda_test.rs): full create/get/update round-trip
2026-04-30 17:25:03 -05:00

68 lines
2.3 KiB
Bash

#!/usr/bin/env bats
# Lambda tests
setup() {
load 'test_helper/common-setup'
FUNC_NAME=""
}
teardown() {
if [ -n "$FUNC_NAME" ]; then
aws_cmd lambda delete-function --function-name "$FUNC_NAME" >/dev/null 2>&1 || true
fi
}
_role="arn:aws:iam::000000000000:role/lambda-role"
_image_uri="000000000000.dkr.ecr.us-east-1.amazonaws.com/fake-repo:latest"
@test "Lambda: ImageConfig.WorkingDirectory is returned in CreateFunction response" {
FUNC_NAME="bats-imgwd-create-$(unique_name)"
run aws_cmd lambda create-function \
--function-name "$FUNC_NAME" \
--package-type Image \
--role "$_role" \
--code "ImageUri=$_image_uri" \
--image-config 'WorkingDirectory=/app'
assert_success
wd=$(json_get "$output" '.ImageConfigResponse.ImageConfig.WorkingDirectory')
[ "$wd" = "/app" ] || { echo "expected WorkingDirectory=/app, got: $wd"; return 1; }
}
@test "Lambda: ImageConfig.WorkingDirectory is persisted and returned by get-function-configuration" {
FUNC_NAME="bats-imgwd-get-$(unique_name)"
aws_cmd lambda create-function \
--function-name "$FUNC_NAME" \
--package-type Image \
--role "$_role" \
--code "ImageUri=$_image_uri" \
--image-config 'WorkingDirectory=/workspace' >/dev/null
run aws_cmd lambda get-function-configuration --function-name "$FUNC_NAME"
assert_success
wd=$(json_get "$output" '.ImageConfigResponse.ImageConfig.WorkingDirectory')
[ "$wd" = "/workspace" ] || { echo "expected WorkingDirectory=/workspace, got: $wd"; return 1; }
}
@test "Lambda: ImageConfig.WorkingDirectory is updated by update-function-configuration" {
FUNC_NAME="bats-imgwd-upd-$(unique_name)"
aws_cmd lambda create-function \
--function-name "$FUNC_NAME" \
--package-type Image \
--role "$_role" \
--code "ImageUri=$_image_uri" \
--image-config 'WorkingDirectory=/initial' >/dev/null
run aws_cmd lambda update-function-configuration \
--function-name "$FUNC_NAME" \
--image-config 'WorkingDirectory=/updated'
assert_success
wd=$(json_get "$output" '.ImageConfigResponse.ImageConfig.WorkingDirectory')
[ "$wd" = "/updated" ] || { echo "expected WorkingDirectory=/updated, got: $wd"; return 1; }
}