mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
refactor(cloudformation): hoist resolveOrDefault onto ProvisionContext (#4049)
Seven per-service provisioners (Lambda, StepFunctions, ElbV2, Events, ApiGatewayRestApi, ApiGatewayV2, Cognito) each carried an identical private resolveOrDefault helper, differing only in argument order. Move it to ProvisionContext as an instance method next to resolveOptional and rewrite the 15 call sites to ctx.resolveOrDefault(props, name, default), removing the copies. Behavior is unchanged: the bodies were byte-identical (resolveOptional plus a non-blank fallback). The monolith's own resolveOrDefault(props, name, engine, default) is left alone: it takes a raw engine rather than a ProvisionContext, is already dead (no callers), and belongs to the later dispatcher-retirement cleanup. Refs #3885
This commit is contained in:
1 parent
3976f2bd05
commit
f9d1b8101c
9 files changed
+36
-48
No files matched your search
+11
@@ -69,6 +69,17 @@ class ProvisionContextTest {
|
||||
assertNull(ctx.priorPhysicalId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveOrDefaultReturnsTheValueOtherwiseTheDefault() {
|
||||
ProvisionContext ctx = context(null);
|
||||
|
||||
assertEquals("HTTP", ctx.resolveOrDefault(props("{\"ProtocolType\":\"HTTP\"}"), "ProtocolType", "WEBSOCKET"));
|
||||
assertEquals("WEBSOCKET", ctx.resolveOrDefault(props("{}"), "ProtocolType", "WEBSOCKET"), "absent falls back");
|
||||
assertEquals("WEBSOCKET", ctx.resolveOrDefault(props("{\"ProtocolType\":\"\"}"), "ProtocolType", "WEBSOCKET"),
|
||||
"blank falls back");
|
||||
assertEquals("WEBSOCKET", ctx.resolveOrDefault(null, "ProtocolType", "WEBSOCKET"), "null props falls back");
|
||||
}
|
||||
|
||||
@Test
|
||||
void stablePhysicalNamePrefersTheTemplatesName() {
|
||||
assertEquals("chosen",
|
||||
|
||||
Reference in new issue
Block a user