Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(lambda): apply Architectures on UpdateFunctionCode (#2907)

BingEdward9b582b309a9b
diff --git a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java
index 6dea6670da..be820bb34e 100644
--- a/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/lambda/LambdaService.java
@@ -533,6 +533,15 @@ public class LambdaService implements ResourceProvider {
}
}
+ if (request.containsKey("Architectures")) {
+ @SuppressWarnings("unchecked")
+ List<String> archs = request.get("Architectures") instanceof List
+ ? (List<String>) request.get("Architectures") : null;
+ if (archs != null && !archs.isEmpty()) {
+ fn.setArchitectures(new ArrayList<>(archs));
+ }
+ }
+
fn.setLastModified(System.currentTimeMillis());
fn.setRevisionId(UUID.randomUUID().toString());
diff --git a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaServiceTest.java
index 1f86e794fd..42e6f29ce9 100644
--- a/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/lambda/LambdaServiceTest.java
@@ -579,6 +579,28 @@ class LambdaServiceTest {
assertNotEquals(originalRevision, updated.getRevisionId());
}
+ @Test
+ void updateFunctionCodeAppliesArchitectures() {
+ Map<String, Object> req = baseRequest("arch-fn");
+ req.put("Architectures", List.of("arm64"));
+ service.createFunction(REGION, req);
+
+ LambdaFunction updated = service.updateFunctionCode(REGION, "arch-fn",
+ Map.of("Architectures", List.of("x86_64")));
+ assertEquals(List.of("x86_64"), updated.getArchitectures());
+ assertEquals(List.of("x86_64"), service.getFunction(REGION, "arch-fn").getArchitectures());
+ }
+
+ @Test
+ void updateFunctionCodeWithoutArchitecturesKeepsExisting() {
+ Map<String, Object> req = baseRequest("arch-keep-fn");
+ req.put("Architectures", List.of("arm64"));
+ service.createFunction(REGION, req);
+
+ LambdaFunction updated = service.updateFunctionCode(REGION, "arch-keep-fn", Map.of());
+ assertEquals(List.of("arm64"), updated.getArchitectures());
+ }
+
@Test
void rehydrateConcurrency_restoresReservedFromStore() {
// Simulate a persisted state: functions already live in the store